[vlc-commits] codec: videotoolbox: select best chroma for SW deinterlacer

Thomas Guillem git at videolan.org
Tue Jan 16 14:17:25 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jan 16 09:50:40 2018 +0100| [71929724f09c85c5ebc79accf74e926934bfe941] | committer: Thomas Guillem

codec: videotoolbox: select best chroma for SW deinterlacer

(cherry picked from commit 19db35a904556dea51a41a160e094e75f6eb47f6)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/codec/videotoolbox.m | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index f0775e0849..d6e0dae06c 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1773,14 +1773,35 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_block)
 
     vlc_mutex_lock(&p_sys->lock);
 
-#if TARGET_OS_IPHONE
     if (p_block->i_flags & BLOCK_FLAG_INTERLACED_MASK)
     {
+#if TARGET_OS_IPHONE
         msg_Warn(p_dec, "VT decoder doesn't handle deinterlacing on iOS, "
                  "aborting...");
         p_sys->vtsession_status = VTSESSION_STATUS_ABORT;
-    }
+#else
+        if (p_sys->i_forced_cvpx_format == 0)
+        {
+            /* In case of interlaced content, force VT to output I420 since our
+             * SW deinterlacer handle this chroma natively. This avoids having
+             * 2 extra conversions (CVPX->I420 then I420->CVPX). */
+
+            p_sys->i_forced_cvpx_format = kCVPixelFormatType_420YpCbCr8Planar;
+            msg_Warn(p_dec, "Interlaced content: forcing VT to output I420");
+            if (p_sys->session != nil && p_sys->vtsession_status == VTSESSION_STATUS_OK)
+            {
+                msg_Warn(p_dec, "restarting vt session (color changed)");
+                vlc_mutex_unlock(&p_sys->lock);
+
+                /* Drain before stopping */
+                Drain(p_dec, false);
+                StopVideoToolbox(p_dec);
+
+                vlc_mutex_lock(&p_sys->lock);
+            }
+        }
 #endif
+    }
 
     if (p_sys->vtsession_status == VTSESSION_STATUS_RESTART)
     {



More information about the vlc-commits mailing list