Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
1641fccd
提交
1641fccd
authored
3月 25, 2016
作者:
Seven Du
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-8836 fix deprecated warning on newer ffmpeg
上级
fdedaadd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
31 行删除
+40
-31
avcodec.c
src/mod/applications/mod_av/avcodec.c
+28
-19
avformat.c
src/mod/applications/mod_av/avformat.c
+12
-12
没有找到文件。
src/mod/applications/mod_av/avcodec.c
浏览文件 @
1641fccd
...
...
@@ -27,7 +27,7 @@
* Anthony Minessale <anthm@freeswitch.org>
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
*
* mod_avcodec -- Codec with libav.org
* mod_avcodec -- Codec with libav.org
and ffmpeg
*
*/
...
...
@@ -425,9 +425,12 @@ static switch_status_t buffer_h263_rfc4629_packets(h264_codec_context_t *context
return
SWITCH_STATUS_SUCCESS
;
}
#ifndef H263_MODE_B
/* this function is depracated from ffmpeg 3.0 and
https://lists.libav.org/pipermail/libav-devel/2015-October/072782.html
*/
void
rtp_callback
(
struct
AVCodecContext
*
avctx
,
void
*
data
,
int
size
,
int
mb_nb
)
{
#ifndef H263_MODE_B
uint8_t
*
d
=
data
;
uint32_t
code
=
(
ntohl
(
*
(
uint32_t
*
)
data
)
&
0xFFFFFC00
)
>>
10
;
h264_codec_context_t
*
context
=
(
h264_codec_context_t
*
)
avctx
->
opaque
;
...
...
@@ -454,8 +457,8 @@ void rtp_callback(struct AVCodecContext *avctx, void *data, int size, int mb_nb)
size > 1500 ? "===============Exceedding MTU===============" : "");
#endif
#endif
}
#endif
const
uint8_t
*
fs_h263_find_resync_marker_reverse
(
const
uint8_t
*
restrict
start
,
const
uint8_t
*
restrict
end
)
...
...
@@ -734,7 +737,7 @@ static switch_status_t consume_h263p_bitstream(h264_codec_context_t *context, sw
}
if
(
frame
->
m
)
{
av_
free_packet
(
&
context
->
encoder_avpacket
);
av_
packet_unref
(
&
context
->
encoder_avpacket
);
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -796,14 +799,14 @@ static switch_status_t consume_nalu(h264_codec_context_t *context, switch_frame_
if
(
!
nalu
->
len
)
{
frame
->
datalen
=
0
;
frame
->
m
=
0
;
if
(
pkt
->
size
>
0
)
av_
free_packet
(
pkt
);
if
(
pkt
->
size
>
0
)
av_
packet_unref
(
pkt
);
context
->
nalu_current_index
=
0
;
return
SWITCH_STATUS_NOTFOUND
;
}
if
(
context
->
av_codec_id
==
AV_CODEC_ID_H263
)
{
return
consume_h263_bitstream
(
context
,
frame
);
}
}
if
(
context
->
av_codec_id
==
AV_CODEC_ID_H263P
)
{
return
consume_h263p_bitstream
(
context
,
frame
);
...
...
@@ -895,10 +898,23 @@ static switch_status_t open_encoder(h264_codec_context_t *context, uint32_t widt
context
->
encoder_ctx
->
bit_rate
=
context
->
bandwidth
*
1024
;
context
->
encoder_ctx
->
rc_max_rate
=
context
->
bandwidth
*
1024
;
context
->
encoder_ctx
->
rc_buffer_size
=
context
->
bandwidth
*
1024
*
4
;
context
->
encoder_ctx
->
rtp_payload_size
=
SLICE_SIZE
;
if
(
context
->
av_codec_id
==
AV_CODEC_ID_H263
||
context
->
av_codec_id
==
AV_CODEC_ID_H263P
)
{
#ifndef H263_MODE_B
# if defined(__ICL) || defined (__INTEL_COMPILER)
# define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))
# define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
# elif defined(_MSC_VER)
# define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996))
# define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
# else
# define FF_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define FF_ENABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
# endif
FF_DISABLE_DEPRECATION_WARNINGS
context
->
encoder_ctx
->
rtp_callback
=
rtp_callback
;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
context
->
encoder_ctx
->
rc_min_rate
=
context
->
encoder_ctx
->
rc_max_rate
;
context
->
encoder_ctx
->
opaque
=
context
;
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"mb_info"
,
SLICE_SIZE
-
8
,
0
);
...
...
@@ -908,39 +924,32 @@ static switch_status_t open_encoder(h264_codec_context_t *context, uint32_t widt
if
(
context
->
hw_encoder
)
{
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"preset"
,
"llhq"
,
0
);
}
else
{
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"preset"
,
"veryfast"
,
0
);
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"tune"
,
"zerolatency"
,
0
);
av_opt_set
(
context
->
encoder_ctx
->
priv_data
,
"profile"
,
"baseline"
,
0
);
//av_opt_set_int(context->encoder_ctx->priv_data, "slice-max-size", SLICE_SIZE, 0);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"slice-max-size"
,
SLICE_SIZE
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"sc_threshold"
,
40
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"b_strategy"
,
1
,
0
);
av_opt_set_int
(
context
->
encoder_ctx
->
priv_data
,
"crf"
,
18
,
0
);
// libx264-medium.ffpreset preset
context
->
encoder_ctx
->
coder_type
=
1
;
// coder = 1
context
->
encoder_ctx
->
flags
|=
CODEC_FLAG_LOOP_FILTER
;
// flags=+loop
context
->
encoder_ctx
->
me_cmp
|=
1
;
// cmp=+chroma, where CHROMA = 1
context
->
encoder_ctx
->
me_method
=
ME_HEX
;
// me_method=hex
//context->encoder_ctx->me_subpel_quality = 7; // subq=7
context
->
encoder_ctx
->
me_range
=
16
;
// me_range=16
context
->
encoder_ctx
->
max_b_frames
=
3
;
// bf=3
//context->encoder_ctx->refs = 3; // refs=3
// libx264-medium.ffpreset preset
context
->
encoder_ctx
->
gop_size
=
250
;
// g=250
context
->
encoder_ctx
->
keyint_min
=
25
;
// keyint_min=25
context
->
encoder_ctx
->
scenechange_threshold
=
40
;
// sc_threshold=40
context
->
encoder_ctx
->
i_quant_factor
=
0
.
71
;
// i_qfactor=0.71
context
->
encoder_ctx
->
b_frame_strategy
=
1
;
// b_strategy=1
context
->
encoder_ctx
->
qcompress
=
0
.
6
;
// qcomp=0.6
context
->
encoder_ctx
->
qmin
=
10
;
// qmin=10
context
->
encoder_ctx
->
qmax
=
51
;
// qmax=51
context
->
encoder_ctx
->
max_qdiff
=
4
;
// qdiff=4
}
}
if
(
avcodec_open2
(
context
->
encoder_ctx
,
context
->
encoder
,
NULL
)
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Could not open codec
\n
"
);
return
SWITCH_STATUS_FALSE
;
...
...
src/mod/applications/mod_av/avformat.c
浏览文件 @
1641fccd
...
...
@@ -367,13 +367,15 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
c
->
ticks_per_frame
=
2
;
c
->
coder_type
=
1
;
// coder = 1
c
->
flags
|=
CODEC_FLAG_LOOP_FILTER
;
// flags=+loop
c
->
me_cmp
|=
1
;
// cmp=+chroma, where CHROMA = 1
c
->
me_method
=
ME_HEX
;
// me_method=hex
c
->
me_range
=
16
;
// me_range=16
c
->
max_b_frames
=
3
;
// bf=3
av_opt_set_int
(
c
->
priv_data
,
"b_strategy"
,
1
,
0
);
av_opt_set_int
(
c
->
priv_data
,
"motion_est"
,
ME_HEX
,
0
);
av_opt_set_int
(
c
->
priv_data
,
"coder"
,
1
,
0
);
switch
(
mm
->
vprofile
)
{
case
SWITCH_VIDEO_PROFILE_BASELINE
:
av_opt_set
(
c
->
priv_data
,
"profile"
,
"baseline"
,
0
);
...
...
@@ -409,14 +411,12 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
c
->
gop_size
=
250
;
// g=250
c
->
keyint_min
=
25
;
// keyint_min=25
c
->
scenechange_threshold
=
40
;
// sc_threshold=40
c
->
i_quant_factor
=
0
.
71
;
// i_qfactor=0.71
c
->
b_frame_strategy
=
1
;
// b_strategy=1
c
->
qcompress
=
0
.
6
;
// qcomp=0.6
c
->
qmin
=
10
;
// qmin=10
c
->
qmax
=
31
;
// qmax=31
c
->
max_qdiff
=
4
;
// qdiff=4
av_opt_set
(
c
->
priv_data
,
"crf"
,
"18"
,
0
);
av_opt_set
_int
(
c
->
priv_data
,
"crf"
,
18
,
0
);
if
(
codec_id
==
AV_CODEC_ID_VP8
)
{
...
...
@@ -726,7 +726,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
switch_mutex_lock
(
eh
->
mutex
);
ret
=
write_frame
(
eh
->
fc
,
&
eh
->
video_st
->
st
->
codec
->
time_base
,
eh
->
video_st
->
st
,
&
pkt
);
switch_mutex_unlock
(
eh
->
mutex
);
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
}
eh
->
in_callback
=
0
;
...
...
@@ -750,7 +750,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
switch_mutex_lock
(
eh
->
mutex
);
ret
=
write_frame
(
eh
->
fc
,
&
eh
->
video_st
->
st
->
codec
->
time_base
,
eh
->
video_st
->
st
,
&
pkt
);
switch_mutex_unlock
(
eh
->
mutex
);
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
if
(
ret
<
0
)
break
;
}
else
{
break
;
...
...
@@ -1094,7 +1094,7 @@ SWITCH_STANDARD_APP(record_av_function)
if
(
got_packet
)
{
ret
=
write_frame
(
fc
,
&
video_st
.
st
->
codec
->
time_base
,
video_st
.
st
,
&
pkt
);
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
goto
again
;
}
}
...
...
@@ -1484,13 +1484,13 @@ again:
if
((
error
=
avcodec_decode_video2
(
context
->
video_st
.
st
->
codec
,
vframe
,
&
got_data
,
&
pkt
))
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Could not decode frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
av_frame_free
(
&
vframe
);
break
;
}
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pkt: %d, pts: %lld dts: %lld\n", pkt.size, pkt.pts, pkt.dts);
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
//if (switch_queue_size(context->eh.video_queue) > 300) {
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Dropping frames\n");
...
...
@@ -1587,12 +1587,12 @@ again:
if
((
error
=
avcodec_decode_audio4
(
context
->
audio_st
.
st
->
codec
,
&
in_frame
,
&
got_data
,
&
pkt
))
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Could not decode frame (error '%s')
\n
"
,
get_error_text
(
error
));
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
break
;
}
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "pkt: %d, decodedddd: %d pts: %lld dts: %lld\n", pkt.size, error, pkt.pts, pkt.dts);
av_
free_packet
(
&
pkt
);
av_
packet_unref
(
&
pkt
);
if
(
got_data
)
{
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got data frm->format: %d samples: %d\n", in_frame.format, in_frame.nb_samples);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论