[vlc-commits] codec: avcodec: use same threshold as vout for frame drop
Francois Cartegnie
git at videolan.org
Thu Nov 1 12:38:54 CET 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Oct 31 12:59:27 2018 +0100| [96561d4db0046e2da3ed8a623cdd98b595f86f76] | committer: Francois Cartegnie
codec: avcodec: use same threshold as vout for frame drop
(cherry picked from commit f94831d7a560b71d05416e087165092ae5fc187c)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=96561d4db0046e2da3ed8a623cdd98b595f86f76
---
modules/codec/avcodec/video.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 664d045c58..8cb4003561 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -740,24 +740,26 @@ static bool check_frame_should_be_dropped( decoder_sys_t *p_sys, AVCodecContext
return false;
}
-static void interpolate_next_pts( decoder_t *p_dec, AVFrame *frame )
+static mtime_t interpolate_next_pts( decoder_t *p_dec, AVFrame *frame )
{
decoder_sys_t *p_sys = p_dec->p_sys;
AVCodecContext *p_context = p_sys->p_context;
if( date_Get( &p_sys->pts ) == VLC_TS_INVALID ||
p_sys->pts.i_divider_num == 0 )
- return;
+ return VLC_TS_INVALID;
int i_tick = p_context->ticks_per_frame;
if( i_tick <= 0 )
i_tick = 1;
/* interpolate the next PTS */
- date_Increment( &p_sys->pts, i_tick + frame->repeat_pict );
+ return date_Increment( &p_sys->pts, i_tick + frame->repeat_pict );
}
-static void update_late_frame_count( decoder_t *p_dec, block_t *p_block, mtime_t current_time, mtime_t i_pts )
+static void update_late_frame_count( decoder_t *p_dec, block_t *p_block,
+ mtime_t current_time, mtime_t i_pts,
+ mtime_t i_next_pts )
{
decoder_sys_t *p_sys = p_dec->p_sys;
/* Update frame late count (except when doing preroll) */
@@ -765,7 +767,9 @@ static void update_late_frame_count( decoder_t *p_dec, block_t *p_block, mtime_t
if( !p_block || !(p_block->i_flags & BLOCK_FLAG_PREROLL) )
i_display_date = decoder_GetDisplayDate( p_dec, i_pts );
- if( i_display_date > VLC_TS_INVALID && i_display_date <= current_time )
+ mtime_t i_threshold = i_next_pts != VLC_TS_INVALID ? (i_next_pts - i_pts) / 2 : 20000;
+
+ if( i_display_date > VLC_TS_INVALID && i_display_date + i_threshold <= current_time )
{
/* Out of preroll, consider only late frames on rising delay */
if( p_sys->b_from_preroll )
@@ -1110,9 +1114,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
if( i_pts > VLC_TS_INVALID )
date_Set( &p_sys->pts, i_pts );
- interpolate_next_pts( p_dec, frame );
+ const mtime_t i_next_pts = interpolate_next_pts(p_dec, frame);
- update_late_frame_count( p_dec, p_block, current_time, i_pts);
+ update_late_frame_count( p_dec, p_block, current_time, i_pts, i_next_pts);
if( !b_need_output_picture ||
( !p_sys->p_va && !frame->linesize[0] ) ||
More information about the vlc-commits
mailing list