[vlc-commits] demux: mp4: read mdcv/clli
Francois Cartegnie
git at videolan.org
Tue Aug 21 20:02:27 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Aug 21 19:39:04 2018 +0200| [cc4ba5d32180e6bed75d3ab6a12aea846011b769] | committer: Francois Cartegnie
demux: mp4: read mdcv/clli
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc4ba5d32180e6bed75d3ab6a12aea846011b769
---
modules/demux/mp4/essetup.c | 4 ++++
modules/demux/mp4/libmp4.c | 47 +++++++++++++++++++++++++++++----------------
modules/demux/mp4/libmp4.h | 2 ++
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 413ac3d251..177acb76b8 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -735,6 +735,8 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
}
const MP4_Box_t *p_SmDm = MP4_BoxGet( p_sample, "SmDm" );
+ if( !p_SmDm )
+ p_SmDm = MP4_BoxGet( p_sample, "mdcv" );
if( p_SmDm && BOXDATA(p_SmDm) )
{
memcpy( p_track->fmt.video.mastering.primaries,
@@ -746,6 +748,8 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
}
const MP4_Box_t *p_CoLL = MP4_BoxGet( p_sample, "CoLL" );
+ if( !p_CoLL )
+ p_CoLL = MP4_BoxGet( p_sample, "clli" );
if( p_CoLL && BOXDATA(p_CoLL) )
{
p_track->fmt.video.lighting.MaxCLL = BOXDATA(p_CoLL)->i_maxCLL;
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 84159d1db1..046186d61b 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1915,17 +1915,25 @@ static int MP4_ReadBox_SmDm( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_ENTER( MP4_Box_data_SmDm_t, NULL );
MP4_Box_data_SmDm_t *p_SmDm = p_box->data.p_SmDm;
- uint8_t i_version;
- uint32_t i_flags;
- MP4_GET1BYTE( i_version );
- MP4_GET3BYTES( i_flags );
- VLC_UNUSED(i_flags);
- if( i_version != 0 )
- MP4_READBOX_EXIT( 0 );
+ /* SmDm: version/flags RGB */
+ /* mdcv: version/flags GBR */
+ if( p_box->i_type != ATOM_mdcv )
+ {
+ uint8_t i_version;
+ uint32_t i_flags;
+ MP4_GET1BYTE( i_version );
+ MP4_GET3BYTES( i_flags );
+ VLC_UNUSED(i_flags);
+ if( i_version != 0 )
+ MP4_READBOX_EXIT( 0 );
+ }
const uint8_t RGB2GBR[3] = {2,0,1};
for(int i=0; i<6; i++)
- MP4_GET2BYTES( p_SmDm->primaries[RGB2GBR[i/2] + i%2] );
+ {
+ int index = (p_box->i_type != ATOM_mdcv) ? RGB2GBR[i/2] + i%2 : i;
+ MP4_GET2BYTES( p_SmDm->primaries[index] );
+ }
for(int i=0; i<2; i++)
MP4_GET2BYTES( p_SmDm->white_point[i] );
MP4_GET4BYTES( p_SmDm->i_luminanceMax );
@@ -1939,13 +1947,16 @@ static int MP4_ReadBox_CoLL( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_ENTER( MP4_Box_data_CoLL_t, NULL );
MP4_Box_data_CoLL_t *p_CoLL = p_box->data.p_CoLL;
- uint8_t i_version;
- uint32_t i_flags;
- MP4_GET1BYTE( i_version );
- MP4_GET3BYTES( i_flags );
- VLC_UNUSED(i_flags);
- if( i_version != 0 )
- MP4_READBOX_EXIT( 0 );
+ if( p_box->i_type != ATOM_clli )
+ {
+ uint8_t i_version;
+ uint32_t i_flags;
+ MP4_GET1BYTE( i_version );
+ MP4_GET3BYTES( i_flags );
+ VLC_UNUSED(i_flags);
+ if( i_version != 0 )
+ MP4_READBOX_EXIT( 0 );
+ }
MP4_GET2BYTES( p_CoLL->i_maxCLL );
MP4_GET2BYTES( p_CoLL->i_maxFALL );
@@ -4740,8 +4751,10 @@ static const struct
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp08 },
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp09 },
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp10 },
- { ATOM_SmDm, MP4_ReadBox_SmDm, ATOM_vpcC }, /* vpx mastering display */
- { ATOM_CoLL, MP4_ReadBox_CoLL, ATOM_vpcC }, /* vpx light level */
+ { ATOM_SmDm, MP4_ReadBox_SmDm, ATOM_vpcC }, /* SMPTE2086 mastering display */
+ { ATOM_mdcv, MP4_ReadBox_SmDm, 0 }, /* */
+ { ATOM_CoLL, MP4_ReadBox_CoLL, ATOM_vpcC }, /* CEA861-3 light level */
+ { ATOM_clli, MP4_ReadBox_CoLL, 0 }, /* */
{ ATOM_dac3, MP4_ReadBox_dac3, 0 },
{ ATOM_dec3, MP4_ReadBox_dec3, 0 },
{ ATOM_dvc1, MP4_ReadBox_dvc1, ATOM_vc1 },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 199a855360..5a8fc87083 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -402,6 +402,8 @@ typedef int64_t stime_t;
#define ATOM_irot VLC_FOURCC( 'i', 'r', 'o', 't' )
#define ATOM_SmDm VLC_FOURCC( 'S', 'm', 'D', 'm' )
#define ATOM_CoLL VLC_FOURCC( 'C', 'o', 'L', 'L' )
+#define ATOM_mdcv VLC_FOURCC( 'm', 'd', 'c', 'v' )
+#define ATOM_clli VLC_FOURCC( 'c', 'l', 'l', 'i' )
#define ATOM_0x40PRM VLC_FOURCC( '@', 'P', 'R', 'M' )
#define ATOM_0x40PRQ VLC_FOURCC( '@', 'P', 'R', 'Q' )
More information about the vlc-commits
mailing list