[vlc-commits] codec: videotoolbox: improve best chroma detection

Thomas Guillem git at videolan.org
Thu Mar 1 10:28:48 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 27 17:59:18 2018 +0100| [197b0b8344be06c4f3ff8bb635bca56f3bc012a6] | committer: Thomas Guillem

codec: videotoolbox: improve best chroma detection

Force a video chroma only if we can display it natively (NV12/P010 via GL
interop).

This commit will also force NV12 chroma for H264 and make sure we don't force a
chroma when it's not YUV420. In that case, we let Videotoolbox decide (probably
BGRA).

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

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

 modules/codec/videotoolbox.m | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 06a7fb0d15..9514156c89 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -201,6 +201,31 @@ static void pic_holder_update_reorder_max(struct pic_holder *, uint8_t);
 
 /* Codec Specific */
 
+static void HXXXGetBestChroma(decoder_t *p_dec)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+
+    if (p_sys->i_cvpx_format != 0)
+        return;
+
+    uint8_t i_chroma_format, i_depth_luma, i_depth_chroma;
+    if (hxxx_helper_get_chroma_chroma(&p_sys->hh, &i_chroma_format, &i_depth_luma,
+                                      &i_depth_chroma) != VLC_SUCCESS)
+        return;
+
+    if (i_chroma_format == 1 /* YUV 4:2:0 */)
+    {
+        if (i_depth_luma == 8 && i_depth_chroma == 8)
+            p_sys->i_cvpx_format = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
+#if !TARGET_OS_IPHONE
+        /* Not for iOS since there is no 10bits textures with the old iOS
+         * openGLES version, and therefore no P010 shaders */
+        else if (i_depth_luma == 10 && i_depth_chroma == 10 && deviceSupportsHEVC())
+            p_sys->i_cvpx_format = 'x420'; /* kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange */
+#endif
+    }
+}
+
 static void GetxPSH264(uint8_t i_pps_id, void *priv,
                       const h264_sequence_parameter_set_t **pp_sps,
                       const h264_picture_parameter_set_t **pp_pps)
@@ -429,6 +454,8 @@ static bool CodecSupportedH264(decoder_t *p_dec)
         return false;
     }
 
+    HXXXGetBestChroma(p_dec);
+
     return true;
 }
 
@@ -722,20 +749,8 @@ static bool LateStartHEVC(decoder_t *p_dec)
 
 static bool CodecSupportedHEVC(decoder_t *p_dec)
 {
-#if !TARGET_OS_IPHONE
-    decoder_sys_t *p_sys = p_dec->p_sys;
+    HXXXGetBestChroma(p_dec);
 
-    if (p_sys->i_cvpx_format == 0)
-    {
-        /* Force P010 chroma instead of RGBA in order to improve performances. */
-        uint8_t i_profile, i_level;
-        if (hxxx_helper_get_current_profile_level(&p_sys->hh, &i_profile,
-                                                  &i_level))
-            return true;
-        if (i_profile == HEVC_PROFILE_MAIN_10)
-            p_sys->i_cvpx_format = 'x420'; /* kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange */
-    }
-#endif
     return true;
 }
 



More information about the vlc-commits mailing list