[vlc-commits] codec: videotoolbox: drain when flushing

Thomas Guillem git at videolan.org
Fri Nov 24 13:12:10 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Nov 24 09:35:07 2017 +0100| [f75db2e7ef22b2bb9bc6e2ade65793163ebea4e5] | committer: Thomas Guillem

codec: videotoolbox: drain when flushing

Clear the DPB queue, wait for for asynchronous frames, re-init the PTS instead
of restarting the VT session.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f75db2e7ef22b2bb9bc6e2ade65793163ebea4e5
---

 modules/codec/videotoolbox.m | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 023f71282d..37fb45b330 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1068,6 +1068,18 @@ static CFMutableDictionaryRef CreateSessionDescriptionFormat(decoder_t *p_dec,
     return decoderConfiguration;
 }
 
+static void PtsInit(decoder_t *p_dec)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+
+    if( p_dec->fmt_in.video.i_frame_rate_base && p_dec->fmt_in.video.i_frame_rate )
+    {
+        date_Init( &p_sys->pts, p_dec->fmt_in.video.i_frame_rate * 2,
+                   p_dec->fmt_in.video.i_frame_rate_base );
+    }
+    else date_Init( &p_sys->pts, 2 * 30000, 1001 );
+}
+
 static int StartVideoToolbox(decoder_t *p_dec)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
@@ -1175,12 +1187,7 @@ static int StartVideoToolbox(decoder_t *p_dec)
     if (status == noErr)
         CFRelease(supportedProps);
 
-    if( p_dec->fmt_in.video.i_frame_rate_base && p_dec->fmt_in.video.i_frame_rate )
-    {
-        date_Init( &p_sys->pts, p_dec->fmt_in.video.i_frame_rate * 2,
-                   p_dec->fmt_in.video.i_frame_rate_base );
-    }
-    else date_Init( &p_sys->pts, 2 * 30000, 1001 );
+    PtsInit(p_dec);
 
     return VLC_SUCCESS;
 }
@@ -1712,12 +1719,16 @@ static void Drain(decoder_t *p_dec, bool flush)
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     /* draining: return last pictures of the reordered queue */
+    vlc_mutex_lock(&p_sys->lock);
+    DrainDPBLocked(p_dec, flush);
+    vlc_mutex_unlock(&p_sys->lock);
+
     if (p_sys->session)
         VTDecompressionSessionWaitForAsynchronousFrames(p_sys->session);
 
     vlc_mutex_lock(&p_sys->lock);
-    DrainDPBLocked(p_dec, flush);
     p_sys->b_vt_flush = false;
+    p_sys->b_vt_feed = false;
     vlc_mutex_unlock(&p_sys->lock);
 }
 
@@ -1726,7 +1737,10 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_block)
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     if (p_sys->b_vt_flush)
-        RestartVideoToolbox(p_dec, false);
+    {
+        Drain(p_dec, true);
+        PtsInit(p_dec);
+    }
 
     if (p_block == NULL)
     {



More information about the vlc-commits mailing list