[vlc-commits] demux: mp4: update from vp8/9/10 spec
Francois Cartegnie
git at videolan.org
Mon Mar 5 17:17:48 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar 5 16:11:27 2018 +0100| [2e6a72d2242ff3ffa81776ce2b542daeaf119444] | committer: Francois Cartegnie
demux: mp4: update from vp8/9/10 spec
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e6a72d2242ff3ffa81776ce2b542daeaf119444
---
modules/demux/Makefile.am | 1 +
modules/demux/mp4/essetup.c | 48 +++++++++++++++++++++++++++++----------------
modules/demux/mp4/libmp4.c | 33 ++++++++++++++++++++++---------
modules/demux/mp4/libmp4.h | 4 +++-
4 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index dba3c4c6b6..6416da98fb 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -204,6 +204,7 @@ libmp4_plugin_la_SOURCES = demux/mp4/mp4.c demux/mp4/mp4.h \
demux/mp4/languages.h \
demux/asf/asfpacket.c demux/asf/asfpacket.h \
demux/mp4/avci.h \
+ demux/mp4/color_specs.h \
demux/mp4/essetup.c demux/mp4/meta.c \
meta_engine/ID3Genres.h
libmp4_plugin_la_LIBADD = $(LIBM)
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 0f785f60ff..d14c441dbb 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -28,6 +28,7 @@
#include "avci.h"
#include "../xiph.h"
#include "../../packetizer/dts_header.h"
+#include "color_config.h"
#include <vlc_demux.h>
#include <vlc_aout.h>
@@ -671,24 +672,37 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
p_track->fmt.i_codec = VLC_CODEC_VP8;
p_track->fmt.i_profile = p_data->i_profile;
p_track->fmt.i_level = p_data->i_level;
- const uint8_t colorspacesmapping[] =
- {
- COLOR_SPACE_UNDEF,
- COLOR_SPACE_BT601,
- COLOR_SPACE_BT709,
- COLOR_SPACE_SMPTE_170,
- COLOR_SPACE_SMPTE_240,
- COLOR_SPACE_BT2020,
- COLOR_SPACE_BT2020,
- COLOR_SPACE_SRGB,
- };
- if( p_data->i_color_space < ARRAY_SIZE(colorspacesmapping) )
- p_track->fmt.video.space = colorspacesmapping[p_data->i_color_space];
- if( p_data->i_xfer_function == 0 )
- p_track->fmt.video.transfer = TRANSFER_FUNC_BT709;
- else if ( p_data->i_xfer_function == 1 )
- p_track->fmt.video.transfer = TRANSFER_FUNC_SMPTE_ST2084;
+ if( p_data->i_version == 0 ) /* old deprecated */
+ {
+ const uint8_t colorspacesmapping[] =
+ {
+ COLOR_SPACE_UNDEF,
+ COLOR_SPACE_BT601,
+ COLOR_SPACE_BT709,
+ COLOR_SPACE_SMPTE_170,
+ COLOR_SPACE_SMPTE_240,
+ COLOR_SPACE_BT2020,
+ COLOR_SPACE_BT2020,
+ COLOR_SPACE_SRGB,
+ };
+ if( p_data->i_color_primaries < ARRAY_SIZE(colorspacesmapping) )
+ p_track->fmt.video.space = colorspacesmapping[p_data->i_color_primaries];
+
+ if( p_data->i_xfer_function == 0 )
+ p_track->fmt.video.transfer = TRANSFER_FUNC_BT709;
+ else if ( p_data->i_xfer_function == 1 )
+ p_track->fmt.video.transfer = TRANSFER_FUNC_SMPTE_ST2084;
+ }
+ else
+ {
+ p_track->fmt.video.primaries =
+ iso_23001_8_cp_to_vlc_primaries( p_data->i_color_primaries );
+ p_track->fmt.video.transfer =
+ iso_23001_8_tc_to_vlc_xfer( p_data->i_xfer_function );
+ p_track->fmt.video.space =
+ iso_23001_8_mc_to_vlc_coeffs( p_data->i_matrix_coeffs );
+ }
p_track->fmt.video.b_color_range_full = p_data->i_fullrange;
p_track->fmt.video.i_bits_per_pixel = p_data->i_bit_depth;
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 665fc6cd64..7c4727c79c 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1981,20 +1981,35 @@ static int MP4_ReadBox_vpcC( stream_t *p_stream, MP4_Box_t *p_box )
if( p_box->i_size < 6 )
MP4_READBOX_EXIT( 0 );
- uint8_t i_version;
- MP4_GET1BYTE( i_version );
- if( i_version != 0 )
+ MP4_GET1BYTE( p_vpcC->i_version );
+ if( p_vpcC->i_version > 1 )
MP4_READBOX_EXIT( 0 );
MP4_GET1BYTE( p_vpcC->i_profile );
MP4_GET1BYTE( p_vpcC->i_level );
MP4_GET1BYTE( p_vpcC->i_bit_depth );
- p_vpcC->i_color_space = p_vpcC->i_bit_depth & 0x0F;
- p_vpcC->i_bit_depth >>= 4;
- MP4_GET1BYTE( p_vpcC->i_chroma_subsampling );
- p_vpcC->i_xfer_function = ( p_vpcC->i_chroma_subsampling & 0x0F ) >> 1;
- p_vpcC->i_fullrange = p_vpcC->i_chroma_subsampling & 0x01;
- p_vpcC->i_chroma_subsampling >>= 4;
+
+ /* Deprecated one
+ https://github.com/webmproject/vp9-dash/blob/master/archive/VPCodecISOMediaFileFormatBinding-v0.docx */
+ if( p_vpcC->i_version == 0 )
+ {
+ p_vpcC->i_color_primaries = p_vpcC->i_bit_depth & 0x0F;
+ p_vpcC->i_bit_depth >>= 4;
+ MP4_GET1BYTE( p_vpcC->i_chroma_subsampling );
+ p_vpcC->i_xfer_function = ( p_vpcC->i_chroma_subsampling & 0x0F ) >> 1;
+ p_vpcC->i_fullrange = p_vpcC->i_chroma_subsampling & 0x01;
+ p_vpcC->i_chroma_subsampling >>= 4;
+ }
+ else
+ {
+ p_vpcC->i_chroma_subsampling = ( p_vpcC->i_bit_depth & 0x0F ) >> 1;
+ p_vpcC->i_fullrange = p_vpcC->i_bit_depth & 0x01;
+ p_vpcC->i_bit_depth >>= 4;
+ MP4_GET1BYTE( p_vpcC->i_color_primaries );
+ MP4_GET1BYTE( p_vpcC->i_xfer_function );
+ MP4_GET1BYTE( p_vpcC->i_matrix_coeffs );
+ }
+
MP4_GET2BYTES( p_vpcC->i_codec_init_datasize );
if( p_vpcC->i_codec_init_datasize > i_read )
p_vpcC->i_codec_init_datasize = i_read;
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index bde7732c8f..83c677a513 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1253,12 +1253,14 @@ typedef struct
typedef struct
{
+ uint8_t i_version;
uint8_t i_profile;
uint8_t i_level;
uint8_t i_bit_depth;
- uint8_t i_color_space;
uint8_t i_chroma_subsampling;
+ uint8_t i_color_primaries;
uint8_t i_xfer_function;
+ uint8_t i_matrix_coeffs;
uint8_t i_fullrange;
uint16_t i_codec_init_datasize;
uint8_t *p_codec_init_data;
More information about the vlc-commits
mailing list