[vlc-devel] [PATCH] es: auto-detect BT2020 if undefined

Thomas Guillem thomas at gllm.fr
Wed Sep 13 12:52:09 CEST 2017


---
 include/vlc_es.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 0617bb72fe..1157a84a74 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -400,10 +400,20 @@ static inline int video_format_Copy( video_format_t *p_dst, const video_format_t
 
 static inline void video_format_AdjustColorSpace( video_format_t *p_fmt )
 {
+    bool b_uhd_10b = false;
+    if ( p_fmt->i_visible_height >= 2160 )
+    {
+        const vlc_chroma_description_t *desc =
+            vlc_fourcc_GetChromaDescription( p_fmt->i_chroma );
+        if( desc && desc->pixel_bits >= 10 )
+            b_uhd_10b = true;
+    }
+
     if ( p_fmt->primaries == COLOR_PRIMARIES_UNDEF )
     {
         if ( p_fmt->i_visible_height > 576 ) // HD
-            p_fmt->primaries = COLOR_PRIMARIES_BT709;
+            p_fmt->primaries = b_uhd_10b ? COLOR_PRIMARIES_BT2020
+                                         : COLOR_PRIMARIES_BT709;
         else if ( p_fmt->i_visible_height > 525 ) // PAL
             p_fmt->primaries = COLOR_PRIMARIES_BT601_625;
         else
@@ -421,7 +431,9 @@ static inline void video_format_AdjustColorSpace( video_format_t *p_fmt )
     if ( p_fmt->space == COLOR_SPACE_UNDEF )
     {
         if ( p_fmt->i_visible_height > 576 ) // HD
-            p_fmt->space = COLOR_SPACE_BT709;
+        {
+            p_fmt->space = b_uhd_10b ? COLOR_SPACE_BT2020 : COLOR_SPACE_BT709;
+        }
         else
             p_fmt->space = COLOR_SPACE_BT601;
     }
-- 
2.11.0



More information about the vlc-devel mailing list