[vlc-commits] packetizer: hxxx: add colour_desc to_vlc helpers

Thomas Guillem git at videolan.org
Sun Apr 17 13:14:15 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sat Apr 16 17:22:49 2016 +0300| [565eeceb6e3a45a72ae2dd3853193b04246d89e8] | committer: Thomas Guillem

packetizer: hxxx: add colour_desc to_vlc helpers

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

 modules/packetizer/hxxx_nal.h |   91 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/modules/packetizer/hxxx_nal.h b/modules/packetizer/hxxx_nal.h
index 6540db5..b8a6610 100644
--- a/modules/packetizer/hxxx_nal.h
+++ b/modules/packetizer/hxxx_nal.h
@@ -21,6 +21,7 @@
 #define HXXX_NAL_H
 
 #include <vlc_common.h>
+#include <vlc_es.h>
 
 static const uint8_t  annexb_startcode4[] = { 0x00, 0x00, 0x00, 0x01 };
 #define annexb_startcode3 (&annexb_startcode4[1])
@@ -41,6 +42,35 @@ enum hxxx_colour_primaries
     HXXX_PRIMARIES_SMPTE_ST_428     = 10,
 };
 
+static inline video_color_primaries_t
+hxxx_colour_primaries_to_vlc( enum hxxx_colour_primaries i_colour )
+{
+    switch( i_colour )
+    {
+    case HXXX_PRIMARIES_BT470BG:
+        return COLOR_PRIMARIES_BT601_625;
+
+    case HXXX_PRIMARIES_BT601_525:
+    case HXXX_PRIMARIES_SMTPE_240M:
+        return COLOR_PRIMARIES_BT601_625;
+
+    case HXXX_PRIMARIES_BT709:
+        return COLOR_PRIMARIES_BT709;
+
+    case HXXX_PRIMARIES_BT2020:
+        return COLOR_PRIMARIES_BT2020;
+
+    case HXXX_PRIMARIES_BT470M:
+    case HXXX_PRIMARIES_RESERVED0:
+    case HXXX_PRIMARIES_UNSPECIFIED:
+    case HXXX_PRIMARIES_RESERVED3:
+    case HXXX_PRIMARIES_GENERIC_FILM:
+    case HXXX_PRIMARIES_SMPTE_ST_428:
+    default:
+        return COLOR_PRIMARIES_UNDEF;
+    }
+}
+
 /* Annex E: Transfer characteristics */
 enum hxxx_transfer_characteristics
 {
@@ -64,6 +94,40 @@ enum hxxx_transfer_characteristics
     HXXX_TRANSFER_SMPTE_ST_428      = 17,
 };
 
+static inline video_transfer_func_t
+hxxx_transfer_characteristics_to_vlc( enum hxxx_transfer_characteristics i_transfer )
+{
+    switch( i_transfer )
+    {
+    case HXXX_TRANSFER_LINEAR:
+        return TRANSFER_FUNC_LINEAR;
+
+    case HXXX_TRANSFER_BT470M:
+        return TRANSFER_FUNC_SRGB;
+
+    case HXXX_TRANSFER_BT709:
+    case HXXX_TRANSFER_BT601_525:
+    case HXXX_TRANSFER_BT2020_V14:
+    case HXXX_TRANSFER_BT2020_V15:
+        return TRANSFER_FUNC_BT709;
+
+    case HXXX_TRANSFER_RESERVED0:
+    case HXXX_TRANSFER_UNSPECIFIED:
+    case HXXX_TRANSFER_RESERVED3:
+    case HXXX_TRANSFER_BT470BG:
+    case HXXX_TRANSFER_SMTPE_240M:
+    case HXXX_TRANSFER_LOG:
+    case HXXX_TRANSFER_LOG_SQRT:
+    case HXXX_TRANSFER_IEC61966_2_4:
+    case HXXX_TRANSFER_BT1361:
+    case HXXX_TRANSFER_IEC61966_2_1:
+    case HXXX_TRANSFER_SMPTE_ST_2084:
+    case HXXX_TRANSFER_SMPTE_ST_428:
+    default:
+        return TRANSFER_FUNC_UNDEF;
+    };
+}
+
 /* Annex E: Matrix coefficients */
 enum hxxx_matrix_coeffs
 {
@@ -80,6 +144,33 @@ enum hxxx_matrix_coeffs
     HXXX_MATRIX_BT2020_CL           = 10,
 };
 
+static inline video_color_space_t
+hxxx_matrix_coeffs_to_vlc( enum hxxx_matrix_coeffs i_transfer )
+{
+    switch( i_transfer )
+    {
+    case HXXX_MATRIX_BT470BG:
+    case HXXX_MATRIX_BT601_525:
+        return COLOR_SPACE_BT601;
+
+    case HXXX_MATRIX_BT709:
+        return COLOR_SPACE_BT709;
+
+    case HXXX_MATRIX_BT2020_NCL:
+    case HXXX_MATRIX_BT2020_CL:
+        return COLOR_SPACE_BT2020;
+
+    case HXXX_MATRIX_IDENTITY:
+    case HXXX_MATRIX_UNSPECIFIED:
+    case HXXX_MATRIX_RESERVED:
+    case HXXX_MATRIX_FCC:
+    case HXXX_MATRIX_SMTPE_240M:
+    case HXXX_MATRIX_YCGCO:
+    default:
+        return COLOR_SPACE_UNDEF;
+    }
+}
+
 /* strips any AnnexB startcode [0] 0 0 1 */
 static inline bool hxxx_strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data )
 {



More information about the vlc-commits mailing list