Commit cc4ba5d3 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: mp4: read mdcv/clli

parent 3e2d5c34
......@@ -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;
......
......@@ -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 },
......
......@@ -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' )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment