[vlc-devel] [PATCH] core: use the decoder input colorimetry when not set on the output

Steve Lhomme robux4 at videolabs.io
Wed Mar 29 10:43:06 CEST 2017


It's better than picking a value when it was actually set on the input of the
decoder by the demuxer/packetizer.
---
 include/vlc_es.h    | 15 +++++++++++----
 src/input/decoder.c |  2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 4210bc0d71..0acd8721da 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -378,11 +378,14 @@ 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 )
+static inline void video_format_AdjustColorSpace( video_format_t *p_fmt,
+                                                  const video_format_t *p_similar )
 {
     if ( p_fmt->primaries == COLOR_PRIMARIES_UNDEF )
     {
-        if ( p_fmt->i_visible_height > 576 ) // HD
+        if ( p_similar && p_similar->primaries != COLOR_PRIMARIES_UNDEF )
+            p_fmt->primaries = p_similar->primaries;
+        else 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;
@@ -392,7 +395,9 @@ static inline void video_format_AdjustColorSpace( video_format_t *p_fmt )
 
     if ( p_fmt->transfer == TRANSFER_FUNC_UNDEF )
     {
-        if ( p_fmt->i_visible_height > 576 ) // HD
+        if ( p_similar && p_similar->transfer != TRANSFER_FUNC_UNDEF )
+            p_fmt->transfer = p_similar->transfer;
+        else if ( p_fmt->i_visible_height > 576 ) // HD
             p_fmt->transfer = TRANSFER_FUNC_BT709;
         else
             p_fmt->transfer = TRANSFER_FUNC_SRGB;
@@ -400,7 +405,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
+        if ( p_similar && p_similar->space != COLOR_SPACE_UNDEF )
+            p_fmt->space = p_similar->space;
+        else if ( p_fmt->i_visible_height > 576 ) // HD
             p_fmt->space = COLOR_SPACE_BT709;
         else
             p_fmt->space = COLOR_SPACE_BT601;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 68cc81b164..6a13d870b8 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -450,7 +450,7 @@ 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 );
+        video_format_AdjustColorSpace( &fmt, &p_dec->fmt_in.video );
 
         vlc_mutex_lock( &p_owner->lock );
 
-- 
2.11.1



More information about the vlc-devel mailing list