[vlc-devel] [PATCH] codec: avcodec: no FRAME threading on unknown/low framerate
Francois Cartegnie
fcvlcdev at free.fr
Tue Aug 21 18:27:46 CEST 2018
fixes always late frames due to threading delay
---
modules/codec/avcodec/video.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index b2aee8ea88..87be13e88c 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -460,12 +460,12 @@ static int OpenVideoCodec( decoder_t *p_dec )
cc_Init( &p_sys->cc );
set_video_color_settings( &p_dec->fmt_in.video, ctx );
- if( p_dec->fmt_in.video.i_frame_rate_base &&
- p_dec->fmt_in.video.i_frame_rate &&
+
+ if( p_dec->fmt_in.video.i_frame_rate_base == 0 ||
(double) p_dec->fmt_in.video.i_frame_rate /
p_dec->fmt_in.video.i_frame_rate_base < 6 )
{
- /* !warn: this disables any threading */
+ /* this disables FF_THREAD_FRAME */
ctx->flags |= AV_CODEC_FLAG_LOW_DELAY;
}
@@ -603,7 +603,8 @@ int InitVideoDec( vlc_object_t *obj )
if( i_thread_count > 1 )
i_thread_count++;
- //FIXME: take in count the decoding time
+ /* FIXME: take in count the decoding time
+ * Frame threading introduces latency */
#if VLC_WINSTORE_APP
i_thread_count = __MIN( i_thread_count, 6 );
#else
@@ -635,6 +636,14 @@ int InitVideoDec( vlc_object_t *obj )
break;
}
+ if( p_context->flags |= AV_CODEC_FLAG_LOW_DELAY )
+ {
+ /* LOW_DELAY already disables threading internally
+ * THREAD_FRAME, by we want it explicit for conditional handling
+ * in our code */
+ p_context->thread_type &= ~FF_THREAD_FRAME;
+ }
+
if( p_context->thread_type & FF_THREAD_FRAME )
p_dec->i_extra_picture_buffers = 2 * p_context->thread_count;
--
2.14.4
More information about the vlc-devel
mailing list