提交 a711f27f 编写于 作者: Z Zhang Rui

ios/VideoToolbox: drop too late frames

上级 d4efdfad
......@@ -3357,6 +3357,16 @@ void ffp_frame_queue_push(FrameQueue *f)
return frame_queue_push(f);
}
int ffp_get_master_sync_type(VideoState *is)
{
return get_master_sync_type(is);
}
double ffp_get_master_clock(VideoState *is)
{
return get_master_clock(is);
}
void ffp_toggle_buffering_l(FFPlayer *ffp, int buffering_on)
{
VideoState *is = ffp->is;
......
......@@ -80,6 +80,9 @@ bool ffp_is_flush_packet(AVPacket *pkt);
Frame *ffp_frame_queue_peek_writable(FrameQueue *f);
void ffp_frame_queue_push(FrameQueue *f);
int ffp_get_master_sync_type(VideoState *is);
double ffp_get_master_clock(VideoState *is);
void ffp_toggle_buffering_l(FFPlayer *ffp, int start_buffering);
void ffp_toggle_buffering(FFPlayer *ffp, int start_buffering);
void ffp_check_buffering_l(FFPlayer *ffp);
......
......@@ -340,6 +340,9 @@ void VTDecoderCallback(void *decompressionOutputRefCon,
return;
}
FFPlayer *ffp = ctx->ffp;
VideoState *is = ffp->is;
sort_queue *newFrame = (sort_queue *)mallocz(sizeof(sort_queue));
{
......@@ -386,6 +389,33 @@ void VTDecoderCallback(void *decompressionOutputRefCon,
goto failed;
}
// FIXME: duplicated code
{
double dpts = NAN;
if (newFrame->pts != AV_NOPTS_VALUE)
dpts = av_q2d(is->video_st->time_base) * newFrame->pts;
if (ffp->framedrop>0 || (ffp->framedrop && ffp_get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) {
if (newFrame->pts != AV_NOPTS_VALUE) {
double diff = dpts - ffp_get_master_clock(is);
if (!isnan(diff) && fabs(diff) < AV_NOSYNC_THRESHOLD &&
diff - is->frame_last_filter_delay < 0 &&
is->viddec.pkt_serial == is->vidclk.serial &&
is->videoq.nb_packets) {
is->frame_drops_early++;
is->continuous_frame_drops_early++;
if (is->continuous_frame_drops_early > ffp->framedrop) {
is->continuous_frame_drops_early = 0;
} else {
// drop too late frame
goto failed;
}
}
}
}
}
if (ctx->new_seg_flag) {
ALOGI("new seg process!!!!");
while (ctx->m_queue_depth > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册