[vlc-commits] packetizer: h264: add h264_get_colorimetry

Thomas Guillem git at videolan.org
Wed Sep 13 11:15:07 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 13 09:42:31 2017 +0200| [0f74383d3474487887b83def4c61751471d1e3e5] | committer: Thomas Guillem

packetizer: h264: add h264_get_colorimetry

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

 modules/packetizer/h264.c     | 13 ++++---------
 modules/packetizer/h264_nal.c | 18 ++++++++++++++++++
 modules/packetizer/h264_nal.h |  6 ++++++
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index f219253e07..44582f1fe9 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -223,15 +223,10 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
                 }
             }
             if( p_dec->fmt_in.video.primaries == COLOR_PRIMARIES_UNDEF )
-            {
-                p_dec->fmt_out.video.primaries =
-                        hxxx_colour_primaries_to_vlc( p_sps->vui.colour.i_colour_primaries );
-                p_dec->fmt_out.video.transfer =
-                        hxxx_transfer_characteristics_to_vlc( p_sps->vui.colour.i_transfer_characteristics );
-                p_dec->fmt_out.video.space =
-                        hxxx_matrix_coeffs_to_vlc( p_sps->vui.colour.i_matrix_coefficients );
-                p_dec->fmt_out.video.b_color_range_full = p_sps->vui.colour.b_full_range;
-            }
+                h264_get_colorimetry( p_sps, &p_dec->fmt_out.video.primaries,
+                                      &p_dec->fmt_out.video.transfer,
+                                      &p_dec->fmt_out.video.space,
+                                      &p_dec->fmt_out.video.b_color_range_full );
         }
     }
 }
diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index 09d8ddaed5..29d5c16666 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -794,6 +794,24 @@ bool h264_get_chroma_luma( const h264_sequence_parameter_set_t *p_sps, uint8_t *
     *pi_depth_chroma = p_sps->i_bit_depth_chroma;
     return true;
 }
+bool h264_get_colorimetry( const h264_sequence_parameter_set_t *p_sps,
+                           video_color_primaries_t *p_primaries,
+                           video_transfer_func_t *p_transfer,
+                           video_color_space_t *p_colorspace,
+                           bool *p_full_range )
+{
+    if( !p_sps->vui.b_valid )
+        return false;
+    *p_primaries =
+        hxxx_colour_primaries_to_vlc( p_sps->vui.colour.i_colour_primaries );
+    *p_transfer =
+        hxxx_transfer_characteristics_to_vlc( p_sps->vui.colour.i_transfer_characteristics );
+    *p_colorspace =
+        hxxx_matrix_coeffs_to_vlc( p_sps->vui.colour.i_matrix_coefficients );
+    *p_full_range = p_sps->vui.colour.b_full_range;
+    return true;
+}
+
 
 bool h264_get_profile_level(const es_format_t *p_fmt, uint8_t *pi_profile,
                             uint8_t *pi_level, uint8_t *pi_nal_length_size)
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index c32610d6a7..4a58a61a0f 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -21,6 +21,7 @@
 # define H264_NAL_H
 
 # include <vlc_common.h>
+# include <vlc_es.h>
 
 #define PROFILE_H264_BASELINE             66
 #define PROFILE_H264_MAIN                 77
@@ -187,6 +188,11 @@ bool h264_get_picture_size( const h264_sequence_parameter_set_t *, unsigned *p_w
                             unsigned *p_vw, unsigned *p_vh );
 bool h264_get_chroma_luma( const h264_sequence_parameter_set_t *, uint8_t *pi_chroma_format,
                            uint8_t *pi_depth_luma, uint8_t *pi_depth_chroma );
+bool h264_get_colorimetry( const h264_sequence_parameter_set_t *p_sps,
+                           video_color_primaries_t *p_primaries,
+                           video_transfer_func_t *p_transfer,
+                           video_color_space_t *p_colorspace,
+                           bool *p_full_range );
 
 /* Get level and Profile from DecoderConfigurationRecord */
 bool h264_get_profile_level(const es_format_t *p_fmt, uint8_t *pi_profile,



More information about the vlc-commits mailing list