[vlc-devel] [PATCH] avcodec: change low delay mode trigger

Francois Cartegnie fcvlcdev at free.fr
Thu Sep 5 20:48:03 CEST 2019


Problem description there:
https://trac.videolan.org/vlc/ticket/22732

To workaround, try to have (max reorder frames + 1 pull)
 durations to not exceed the standard caching delay.

With file caching (300ms) it's below 16 fps.

---
 modules/codec/avcodec/video.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 674bc918e8..e15b5d3191 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -475,11 +475,19 @@ static int OpenVideoCodec( decoder_t *p_dec )
 
     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 &&
-        (double) p_dec->fmt_in.video.i_frame_rate /
-                 p_dec->fmt_in.video.i_frame_rate_base < 6 )
+        p_dec->fmt_in.video.i_frame_rate )
     {
-        ctx->flags |= AV_CODEC_FLAG_LOW_DELAY;
+        vlc_tick_t ft = CLOCK_FREQ *
+                        p_dec->fmt_in.video.i_frame_rate_base /
+                        p_dec->fmt_in.video.i_frame_rate;
+        /* max retention should be reorder depth + 1
+         * compared to default pts-delay */
+        if( ft * (4+1) > VLC_TICK_FROM_MS(300) )
+        {
+            /* Disables frame threading for anything < ~~ 16fps */
+            msg_Warn(p_dec,"Switching to low delay mode");
+            ctx->flags |= AV_CODEC_FLAG_LOW_DELAY;
+        }
     }
 
     if( var_InheritBool(p_dec, "low-delay") )
-- 
2.21.0



More information about the vlc-devel mailing list