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

Steve Lhomme git at videolan.org
Sun Apr 17 11:46:43 CEST 2016


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Sun Apr 17 12:43:45 2016 +0300| [ce40fcaff24f49aaf69cfe02b90ede02181c0ac4] | committer: Jean-Baptiste Kempf

decoder: adjust the unknown colorimetry values because getting a vout

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 include/vlc_es.h    |   29 +++++++++++++++++++++++++++++
 src/input/decoder.c |    2 ++
 2 files changed, 31 insertions(+)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 751ea6f..566f31e 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -309,6 +309,35 @@ static inline int video_format_Copy( video_format_t *p_dst, const video_format_t
     return VLC_SUCCESS;
 }
 
+static inline void video_format_AdjustColorSpace( video_format_t *p_fmt )
+{
+    if ( p_fmt->primaries == COLOR_PRIMARIES_UNDEF )
+    {
+        if ( p_fmt->i_visible_height > 576 ) // HD
+            p_fmt->primaries = COLOR_PRIMARIES_BT709;
+        else if ( p_fmt->i_visible_height > 525 ) // PAL
+            p_fmt->primaries = COLOR_PRIMARIES_BT601_625;
+        else
+            p_fmt->primaries = COLOR_PRIMARIES_BT601_525;
+    }
+
+    if ( p_fmt->transfer == TRANSFER_FUNC_UNDEF )
+    {
+        if ( p_fmt->i_visible_height > 576 ) // HD
+            p_fmt->transfer = TRANSFER_FUNC_BT709;
+        else
+            p_fmt->transfer = TRANSFER_FUNC_SRGB;
+    }
+
+    if ( p_fmt->space == COLOR_SPACE_UNDEF )
+    {
+        if ( p_fmt->i_visible_height > 576 ) // HD
+            p_fmt->space = COLOR_SPACE_BT709;
+        else
+            p_fmt->space = COLOR_SPACE_BT601;
+    }
+}
+
 /**
  * Cleanup and free palette of this video_format_t
  * \param p_src video_format_t structure to clean
diff --git a/src/input/decoder.c b/src/input/decoder.c
index a1d7414..a881a06 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -394,6 +394,8 @@ 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 );
 
+        video_format_AdjustColorSpace( &fmt );
+
         vlc_mutex_lock( &p_owner->lock );
 
         p_vout = p_owner->p_vout;



More information about the vlc-commits mailing list