Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ijkplayer
提交
540f69be
I
ijkplayer
项目概览
NotesChapter
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ijkplayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
540f69be
编写于
2月 26, 2014
作者:
B
bbcallen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove ugly drop triky
上级
ac84f3d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
61 deletion
+32
-61
ijkmedia/ijkplayer/ff_ffplay.c
ijkmedia/ijkplayer/ff_ffplay.c
+31
-56
ijkmedia/ijkplayer/ff_ffplay_def.h
ijkmedia/ijkplayer/ff_ffplay_def.h
+1
-5
未找到文件。
ijkmedia/ijkplayer/ff_ffplay.c
浏览文件 @
540f69be
...
@@ -42,8 +42,8 @@
...
@@ -42,8 +42,8 @@
// #define FFP_SHOW_FPS
// #define FFP_SHOW_FPS
// #define FFP_SHOW_VDPS
// #define FFP_SHOW_VDPS
//
#define FFP_SHOW_AUDIO_DELAY
#define FFP_SHOW_AUDIO_DELAY
//
#define FFP_SHOW_DEMUX_CACHE
#define FFP_SHOW_DEMUX_CACHE
static
AVPacket
flush_pkt
;
static
AVPacket
flush_pkt
;
...
@@ -912,42 +912,19 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
...
@@ -912,42 +912,19 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
return
0
;
return
0
;
}
}
if
(
is
->
dropping_frame
)
{
if
(
pkt
->
flags
&
AV_PKT_FLAG_KEY
)
{
ALOGD
(
"skip frame(fast): end
\n
"
);
is
->
dropping_frame
=
0
;
avcodec_flush_buffers
(
is
->
video_st
->
codec
);
}
else
{
return
0
;
}
}
// drop packet only if there is enough cached buffer
int
can_drop_pkt
=
ffp
->
pktdrop
>
0
||
(
ffp
->
pktdrop
&&
get_master_sync_type
(
is
)
!=
AV_SYNC_VIDEO_MASTER
);
int64_t
least_cached_duration
=
DEFAULT_MAX_HIGH_WATER_MARK_IN_MS
+
2
*
ffp
->
dropdelay
;
if
(
can_drop_pkt
&&
is
->
frame_drops_early
>
6
&&
((
is
->
videoq_duration
==
-
1
)
||
is
->
videoq_duration
>
least_cached_duration
)
&&
((
is
->
videoq_duration
==
-
1
)
||
is
->
audioq_duration
>
least_cached_duration
))
{
ALOGD
(
"skip frame: start
\n
"
);
is
->
dropping_frame
=
1
;
is
->
frame_drops_early
=
0
;
avcodec_flush_buffers
(
is
->
video_st
->
codec
);
return
0
;
}
#ifdef FFP_SHOW_VDPS
#ifdef FFP_SHOW_VDPS
int64_t
start
=
SDL_GetTickHR
();
int64_t
start
=
SDL_GetTickHR
();
#endif
#endif
if
(
avcodec_decode_video2
(
is
->
video_st
->
codec
,
frame
,
&
got_picture
,
pkt
)
<
0
)
if
(
avcodec_decode_video2
(
is
->
video_st
->
codec
,
frame
,
&
got_picture
,
pkt
)
<
0
)
return
0
;
return
0
;
#ifdef FFP_SHOW_VDPS
#ifdef FFP_SHOW_VDPS
int64_t
dur
=
SDL_GetTickHR
()
-
start
;
int64_t
dur
=
SDL_GetTickHR
()
-
start
;
g_vdps_total_time
+=
dur
;
g_vdps_total_time
+=
dur
;
g_vdps_counter
++
;
g_vdps_counter
++
;
int64_t
avg_frame_time
=
g_vdps_total_time
/
g_vdps_counter
;
int64_t
avg_frame_time
=
g_vdps_total_time
/
g_vdps_counter
;
double
fps
=
1
.
0
f
/
avg_frame_time
*
1000
;
double
fps
=
1
.
0
f
/
avg_frame_time
*
1000
;
ALOGE
(
"vdps: [%f][%d] %"
PRId64
" ms/frame, vdps=%f, +%"
PRId64
"
\n
"
,
ALOGE
(
"vdps: [%f][%d] %"
PRId64
" ms/frame, vdps=%f, +%"
PRId64
"
\n
"
,
frame
->
pts
,
g_vdps_counter
,
(
int64_t
)
avg_frame_time
,
fps
,
dur
);
frame
->
pts
,
g_vdps_counter
,
(
int64_t
)
avg_frame_time
,
fps
,
dur
);
#endif
#endif
if
(
!
got_picture
&&
!
pkt
->
data
)
{
if
(
!
got_picture
&&
!
pkt
->
data
)
{
...
@@ -972,35 +949,23 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
...
@@ -972,35 +949,23 @@ static int get_video_frame(FFPlayer *ffp, AVFrame *frame, AVPacket *pkt, int *se
frame
->
sample_aspect_ratio
=
av_guess_sample_aspect_ratio
(
is
->
ic
,
is
->
video_st
,
frame
);
frame
->
sample_aspect_ratio
=
av_guess_sample_aspect_ratio
(
is
->
ic
,
is
->
video_st
,
frame
);
int
can_drop_frame
=
ffp
->
framedrop
>
0
||
(
ffp
->
framedrop
&&
get_master_sync_type
(
is
)
!=
AV_SYNC_VIDEO_MASTER
);
if
(
ffp
->
framedrop
>
0
||
(
ffp
->
framedrop
&&
get_master_sync_type
(
is
)
!=
AV_SYNC_VIDEO_MASTER
))
{
if
(
can_drop_frame
||
can_drop_pkt
)
{
int
frame_delayed
=
0
;
SDL_LockMutex
(
is
->
pictq_mutex
);
SDL_LockMutex
(
is
->
pictq_mutex
);
if
(
is
->
frame_last_pts
!=
AV_NOPTS_VALUE
&&
frame
->
pts
!=
AV_NOPTS_VALUE
)
{
if
(
is
->
frame_last_pts
!=
AV_NOPTS_VALUE
&&
frame
->
pts
!=
AV_NOPTS_VALUE
)
{
double
clockdiff
=
get_clock
(
&
is
->
vidclk
)
-
get_master_clock
(
is
);
double
clockdiff
=
get_clock
(
&
is
->
vidclk
)
-
get_master_clock
(
is
);
double
ptsdiff
=
dpts
-
is
->
frame_last_pts
;
double
ptsdiff
=
dpts
-
is
->
frame_last_pts
;
if
(
!
isnan
(
clockdiff
)
&&
fabs
(
clockdiff
)
<
AV_NOSYNC_THRESHOLD
&&
if
(
!
isnan
(
clockdiff
)
&&
fabs
(
clockdiff
)
<
AV_NOSYNC_THRESHOLD
&&
!
isnan
(
ptsdiff
)
&&
ptsdiff
>
0
&&
ptsdiff
<
AV_NOSYNC_THRESHOLD
&&
!
isnan
(
ptsdiff
)
&&
ptsdiff
>
0
&&
ptsdiff
<
AV_NOSYNC_THRESHOLD
&&
clockdiff
+
ptsdiff
-
is
->
frame_last_filter_delay
<
(
0
-
ffp
->
dropdelay
)
&&
clockdiff
+
ptsdiff
-
is
->
frame_last_filter_delay
<
0
&&
*
serial
==
is
->
vidclk
.
serial
&&
is
->
videoq
.
nb_packets
)
{
is
->
videoq
.
nb_packets
)
{
*
is_too_late
=
1
;
is
->
frame_last_dropped_pos
=
av_frame_get_pkt_pos
(
frame
);
if
(
can_drop_frame
)
{
is
->
frame_last_dropped_pts
=
dpts
;
is
->
frame_last_dropped_pos
=
av_frame_get_pkt_pos
(
frame
);
is
->
frame_last_dropped_serial
=
*
serial
;
is
->
frame_last_dropped_pts
=
dpts
;
is
->
frame_drops_early
++
;
is
->
frame_last_dropped_serial
=
*
serial
;
av_frame_unref
(
frame
);
is
->
frame_drops_early
++
;
ret
=
0
;
av_frame_unref
(
frame
);
ret
=
0
;
}
if
(
can_drop_pkt
)
{
is
->
frame_drops_early
++
;
frame_delayed
=
1
;
}
}
}
}
}
if
(
!
frame_delayed
)
is
->
frame_drops_early
=
0
;;
SDL_UnlockMutex
(
is
->
pictq_mutex
);
SDL_UnlockMutex
(
is
->
pictq_mutex
);
}
}
...
@@ -2304,17 +2269,27 @@ static int read_thread(void *arg)
...
@@ -2304,17 +2269,27 @@ static int read_thread(void *arg)
int64_t
audio_cached_duration
=
-
1
;
int64_t
audio_cached_duration
=
-
1
;
int64_t
video_cached_duration
=
-
1
;
int64_t
video_cached_duration
=
-
1
;
if
(
is
->
audio_st
&&
is
->
audio_st
->
time_base
.
den
>
0
&&
is
->
audio_st
->
time_base
.
num
>
0
)
if
(
is
->
audio_st
&&
is
->
audio_st
->
time_base
.
den
>
0
&&
is
->
audio_st
->
time_base
.
num
>
0
)
{
audio_cached_duration
=
is
->
audioq
.
duration
*
av_q2d
(
is
->
audio_st
->
time_base
)
*
1000
;
audio_cached_duration
=
is
->
audioq
.
duration
*
av_q2d
(
is
->
audio_st
->
time_base
)
*
1000
;
#ifdef FFP_SHOW_DEMUX_CACHE
int
video_cached_percent
=
(
int
)
av_rescale
(
audio_cached_duration
,
1005
,
hwm_in_ms
*
10
);
ALOGE
(
"audio cache=%%%d (%d/%d)
\n
"
,
video_cached_percent
,
(
int
)
audio_cached_duration
,
hwm_in_ms
);
#endif
}
if
(
is
->
video_st
&&
is
->
video_st
->
time_base
.
den
>
0
&&
is
->
video_st
->
time_base
.
num
>
0
)
if
(
is
->
video_st
&&
is
->
video_st
->
time_base
.
den
>
0
&&
is
->
video_st
->
time_base
.
num
>
0
)
{
video_cached_duration
=
is
->
videoq
.
duration
*
av_q2d
(
is
->
video_st
->
time_base
)
*
1000
;
video_cached_duration
=
is
->
videoq
.
duration
*
av_q2d
(
is
->
video_st
->
time_base
)
*
1000
;
#ifdef FFP_SHOW_DEMUX_CACHE
int
audio_cached_percent
=
(
int
)
av_rescale
(
video_cached_duration
,
1005
,
hwm_in_ms
*
10
);
ALOGE
(
"video cache=%%%d (%d/%d)
\n
"
,
audio_cached_percent
,
(
int
)
video_cached_duration
,
hwm_in_ms
);
#endif
}
is
->
audioq_duration
=
audio_cached_duration
;
is
->
audioq_duration
=
audio_cached_duration
;
is
->
videoq_duration
=
video_cached_duration
;
is
->
videoq_duration
=
video_cached_duration
;
if
(
video_cached_duration
>=
0
&&
audio_cached_duration
>=
0
)
{
if
(
video_cached_duration
>=
0
&&
audio_cached_duration
>=
0
)
{
cached_duration_in_ms
=
(
int
)
IJKM
AX
(
video_cached_duration
,
audio_cached_duration
);
cached_duration_in_ms
=
(
int
)
IJKM
IN
(
video_cached_duration
,
audio_cached_duration
);
}
else
if
(
video_cached_duration
>=
0
)
{
}
else
if
(
video_cached_duration
>=
0
)
{
cached_duration_in_ms
=
(
int
)
video_cached_duration
;
cached_duration_in_ms
=
(
int
)
video_cached_duration
;
}
else
if
(
audio_cached_duration
>=
0
)
{
}
else
if
(
audio_cached_duration
>=
0
)
{
...
...
ijkmedia/ijkplayer/ff_ffplay_def.h
浏览文件 @
540f69be
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define DEFAULT_HIGH_WATER_MARK_IN_BYTES (128 * 1024)
#define DEFAULT_HIGH_WATER_MARK_IN_BYTES (128 * 1024)
#define DEFAULT_MAX_HIGH_WATER_MARK_IN_MS (
10
* 1000)
#define DEFAULT_MAX_HIGH_WATER_MARK_IN_MS (
5
* 1000)
#define DEFAULT_NORMAL_HIGH_WATER_MARK_IN_MS (2 * 1000)
#define DEFAULT_NORMAL_HIGH_WATER_MARK_IN_MS (2 * 1000)
#define DEFAULT_FAST_HIGH_WATER_MARK_IN_MS (100)
#define DEFAULT_FAST_HIGH_WATER_MARK_IN_MS (100)
...
@@ -394,8 +394,6 @@ typedef struct FFPlayer {
...
@@ -394,8 +394,6 @@ typedef struct FFPlayer {
#endif
#endif
int
loop
;
int
loop
;
int
framedrop
;
int
framedrop
;
int
pktdrop
;
double
dropdelay
;
int
infinite_buffer
;
int
infinite_buffer
;
enum
ShowMode
show_mode
;
enum
ShowMode
show_mode
;
char
*
audio_codec_name
;
char
*
audio_codec_name
;
...
@@ -479,8 +477,6 @@ inline static void ffp_reset_internal(FFPlayer *ffp)
...
@@ -479,8 +477,6 @@ inline static void ffp_reset_internal(FFPlayer *ffp)
ffp
->
autoexit
=
0
;
ffp
->
autoexit
=
0
;
ffp
->
loop
=
1
;
ffp
->
loop
=
1
;
ffp
->
framedrop
=
0
;
ffp
->
framedrop
=
0
;
ffp
->
pktdrop
=
0
;
ffp
->
dropdelay
=
0
.
5
f
;
ffp
->
infinite_buffer
=
-
1
;
ffp
->
infinite_buffer
=
-
1
;
ffp
->
show_mode
=
SHOW_MODE_NONE
;
ffp
->
show_mode
=
SHOW_MODE_NONE
;
av_freep
(
&
ffp
->
audio_codec_name
);
av_freep
(
&
ffp
->
audio_codec_name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录