[vlc-commits] demux: ts: set j2k color profile
Francois Cartegnie
git at videolan.org
Tue Jul 25 14:07:39 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 24 15:54:44 2017 +0200| [b12b10d04c504d03fba5e2fd2d3be33222d8f5f1] | committer: Francois Cartegnie
demux: ts: set j2k color profile
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b12b10d04c504d03fba5e2fd2d3be33222d8f5f1
---
modules/codec/jpeg2000.h | 98 +++++++++++++++++++++++++++++++++++++++++++++
modules/demux/Makefile.am | 2 +-
modules/demux/mpeg/ts_psi.c | 5 +++
3 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/modules/codec/jpeg2000.h b/modules/codec/jpeg2000.h
new file mode 100644
index 0000000000..8ea64ecd0b
--- /dev/null
+++ b/modules/codec/jpeg2000.h
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * jpeg2000.h J2K definitions
+ *****************************************************************************
+ * Copyright (C) 2017 VideoLAN Authors
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifndef VLC_JPEG2000_H
+#define VLC_JPEG2000_H
+
+enum j2k_color_specs_e
+{
+ J2K_COLOR_SPEC_UNKNOWN = 0,
+ J2K_COLOR_SPEC_SRGB,
+ J2K_COLOR_SPEC_REC_601,
+ J2K_COLOR_SPEC_REC_709,
+ J2K_COLOR_SPEC_CIE_LUV,
+ J2K_COLOR_SPEC_CIE_XYZ,
+ J2K_COLOR_SPEC_REC_2020,
+ J2K_COLOR_SPEC_SMPTE_2084,
+};
+
+static const struct
+{
+ video_color_primaries_t primaries;
+ video_transfer_func_t transfer;
+ video_color_space_t space;
+} j2k_color_specifications[] = {
+ [J2K_COLOR_SPEC_UNKNOWN] = { COLOR_PRIMARIES_UNDEF,
+ TRANSFER_FUNC_UNDEF,
+ COLOR_SPACE_UNDEF },
+ [J2K_COLOR_SPEC_SRGB] = { COLOR_PRIMARIES_SRGB,
+ TRANSFER_FUNC_SRGB,
+ COLOR_SPACE_SRGB },
+ [J2K_COLOR_SPEC_REC_601] = { COLOR_PRIMARIES_BT601_625,
+ TRANSFER_FUNC_SMPTE_170,
+ COLOR_SPACE_BT601 },
+ [J2K_COLOR_SPEC_REC_709] = { COLOR_PRIMARIES_BT709,
+ TRANSFER_FUNC_BT709,
+ COLOR_SPACE_BT709 },
+ [J2K_COLOR_SPEC_CIE_LUV] = { COLOR_PRIMARIES_UNDEF,
+ TRANSFER_FUNC_UNDEF,
+ COLOR_SPACE_UNDEF },
+ [J2K_COLOR_SPEC_CIE_XYZ] = { COLOR_PRIMARIES_UNDEF,
+ TRANSFER_FUNC_UNDEF,
+ COLOR_SPACE_UNDEF },
+ [J2K_COLOR_SPEC_REC_2020] ={ COLOR_PRIMARIES_BT2020,
+ TRANSFER_FUNC_BT2020,
+ COLOR_SPACE_BT2020 },
+ [J2K_COLOR_SPEC_SMPTE_2084]={ COLOR_PRIMARIES_SMTPE_170,
+ TRANSFER_FUNC_SMPTE_ST2084,
+ COLOR_SPACE_BT2020 },
+};
+
+static inline void j2k_fill_color_profile( enum j2k_color_specs_e e,
+ video_color_primaries_t *primaries,
+ video_transfer_func_t *transfer,
+ video_color_space_t *space )
+{
+ if( e > J2K_COLOR_SPEC_UNKNOWN && e <= J2K_COLOR_SPEC_SMPTE_2084 )
+ {
+ *primaries = j2k_color_specifications[e].primaries;
+ *transfer = j2k_color_specifications[e].transfer;
+ *space = j2k_color_specifications[e].space;
+ }
+}
+
+static inline enum j2k_color_specs_e
+ j2k_get_color_spec( video_color_primaries_t primaries,
+ video_transfer_func_t transfer ,
+ video_color_space_t space )
+{
+ enum j2k_color_specs_e e;
+ for( e = J2K_COLOR_SPEC_UNKNOWN; e <= J2K_COLOR_SPEC_SMPTE_2084; e++ )
+ {
+ if( primaries == j2k_color_specifications[e].primaries &&
+ transfer == j2k_color_specifications[e].transfer &&
+ space == j2k_color_specifications[e].space )
+ {
+ return e;
+ }
+ }
+ return J2K_COLOR_SPEC_UNKNOWN;
+}
+
+#endif
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index b2e9443c3f..584ddd479a 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -263,7 +263,7 @@ libts_plugin_la_SOURCES = demux/mpeg/ts.c demux/mpeg/ts.h \
mux/mpeg/tables.c mux/mpeg/tables.h \
mux/mpeg/tsutil.c mux/mpeg/tsutil.h \
access/dtv/en50221_capmt.h \
- codec/scte18.h \
+ codec/jpeg2000.h codec/scte18.h \
codec/atsc_a65.c codec/atsc_a65.h \
codec/opus_header.c
libts_plugin_la_CFLAGS = $(AM_CFLAGS) $(DVBPSI_CFLAGS)
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index e19426bf10..fd4a800a8d 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -44,6 +44,7 @@
#include "timestamps.h"
+#include "../../codec/jpeg2000.h"
#include "../../codec/opus_header.h"
#include "sections.h"
@@ -540,6 +541,10 @@ static void SetupJ2KDescriptors( demux_t *p_demux, ts_es_t *p_es, const dvbpsi_p
p_es->fmt.video.i_height = GetDWBE(&p_dr->p_data[6]);
p_es->fmt.video.i_frame_rate_base = GetWBE(&p_dr->p_data[18]);
p_es->fmt.video.i_frame_rate = GetWBE(&p_dr->p_data[20]);
+ j2k_fill_color_profile( p_dr->p_data[21],
+ &p_es->fmt.video.primaries,
+ &p_es->fmt.video.transfer,
+ &p_es->fmt.video.space );
p_es->b_interlaced = p_dr->p_data[23] & 0x40;
if( p_dr->i_length > 24 )
{
More information about the vlc-commits
mailing list