[vlc-devel] [PATCH] decoder: adjust the unknown colorimetry values because getting a vout

Steve Lhomme robux4 at videolabs.io
Sat Apr 16 15:50:35 CEST 2016


---
 src/input/decoder.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index a1d7414..101131a 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -394,6 +394,44 @@ static int vout_update_format( decoder_t *p_dec )
         vlc_ureduce( &fmt.i_sar_num, &fmt.i_sar_den,
                      fmt.i_sar_num, fmt.i_sar_den, 50000 );
 
+        if ( fmt.primaries == COLOR_PRIMARIES_UNDEF )
+        {
+            if ( ( fmt.i_bits_per_pixel == 0 || fmt.i_bits_per_pixel >= 10) &&
+                 ( fmt.i_visible_height >= 2000 || fmt.i_visible_height >= 3800 ) )
+                fmt.primaries = COLOR_PRIMARIES_BT2020;
+            else if ( fmt.i_visible_height > 576 )
+                fmt.primaries = COLOR_PRIMARIES_BT709;
+            else if ( fmt.i_visible_height >= 480 )
+                fmt.primaries = COLOR_PRIMARIES_BT601_625;
+            else
+                fmt.primaries = COLOR_PRIMARIES_BT601_525;
+            msg_Info( &fmt, "Forcing color primaries to %d", fmt.primaries  );
+        }
+
+        if ( fmt.transfer == TRANSFER_FUNC_UNDEF )
+        {
+            if ( ( fmt.i_bits_per_pixel == 0 || fmt.i_bits_per_pixel >= 10) &&
+                 ( fmt.i_visible_height >= 2000 || fmt.i_visible_height >= 3800 ) )
+                fmt.transfer = TRANSFER_FUNC_BT2020;
+            else if ( fmt.i_visible_height > 576 )
+                fmt.transfer = TRANSFER_FUNC_BT709;
+            else
+                fmt.transfer = TRANSFER_FUNC_SRGB;
+            msg_Info( &fmt, "Forcing color transfer curve to %d", fmt.transfer  );
+        }
+
+        if ( fmt.space == COLOR_SPACE_UNDEF )
+        {
+            if ( ( fmt.i_bits_per_pixel == 0 || fmt.i_bits_per_pixel >= 10) &&
+                 ( fmt.i_visible_height >= 2000 || fmt.i_visible_height >= 3800 ) )
+                fmt.space = COLOR_SPACE_BT2020_LIMITED;
+            else if ( fmt.i_visible_height > 576 )
+                fmt.space = COLOR_SPACE_BT709_LIMITED;
+            else
+                fmt.space = COLOR_SPACE_BT601_LIMITED;
+            msg_Info( &fmt, "Forcing color range to %d", fmt.space  );
+        }
+
         vlc_mutex_lock( &p_owner->lock );
 
         p_vout = p_owner->p_vout;
-- 
2.7.0



More information about the vlc-devel mailing list