[vlc-devel] [PATCH 04/10] avcodec: don't call mdate() so often in video decoding
ileoo at videolan.org
ileoo at videolan.org
Sun Sep 4 14:30:08 CEST 2016
From: Ilkka Ollakka <ileoo at videolan.org>
---
modules/codec/avcodec/video.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 5857515..f4b682f 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -603,7 +603,7 @@ static bool check_block_validity( decoder_sys_t *p_sys, block_t *block )
return true;
}
-static bool check_block_being_late( decoder_sys_t *p_sys, block_t *block )
+static bool check_block_being_late( decoder_sys_t *p_sys, block_t *block, mtime_t current_time)
{
if( !block )
return false;
@@ -618,7 +618,7 @@ static bool check_block_being_late( decoder_sys_t *p_sys, block_t *block )
if( p_sys->i_late_frames <= 0 )
return false;
- if( mdate() - p_sys->i_late_frames_start > INT64_C(5000000))
+ if( current_time - p_sys->i_late_frames_start > INT64_C(5000000))
{
if( p_sys->i_pts > VLC_TS_INVALID )
{
@@ -671,6 +671,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
/* Boolean if we assume that we should get valid pic as result */
bool b_need_output_picture = true;
block_t *p_block;
+ mtime_t current_time = VLC_TS_INVALID;
if( !p_context->extradata_size && p_dec->fmt_in.i_extra )
{
@@ -693,7 +694,8 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
if( !check_block_validity( p_sys, p_block ) )
return NULL;
- if( p_dec->b_frame_drop_allowed && check_block_being_late( p_sys, p_block) )
+ current_time = mdate();
+ if( p_dec->b_frame_drop_allowed && check_block_being_late( p_sys, p_block, current_time) )
{
msg_Err( p_dec, "more than 5 seconds of late video -> "
"dropping frame (computer too slow ?)" );
@@ -871,15 +873,15 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
interpolate_next_pts( p_dec, frame );
/* Update frame late count (except when doing preroll) */
- mtime_t i_display_date = 0;
+ mtime_t i_display_date = VLC_TS_INVALID;
if( !p_block || !(p_block->i_flags & BLOCK_FLAG_PREROLL) )
i_display_date = decoder_GetDisplayDate( p_dec, i_pts );
- if( i_display_date > 0 && i_display_date <= mdate() )
+ if( i_display_date > VLC_TS_INVALID && i_display_date <= current_time )
{
p_sys->i_late_frames++;
if( p_sys->i_late_frames == 1 )
- p_sys->i_late_frames_start = mdate();
+ p_sys->i_late_frames_start = current_time;
}
else
{
--
2.6.6
More information about the vlc-devel
mailing list