Commit 45c2a475 authored by Adrien Maglo's avatar Adrien Maglo Committed by Thomas Guillem

demux: mp4: read and save ambisonics metadata

From the Google specification:
https://github.com/google/spatial-media/blob/master/docs/spatial-audio-rfc.mdSigned-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 9e2f0ba6
...@@ -1183,6 +1183,11 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample ) ...@@ -1183,6 +1183,11 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
break; break;
} }
/* Ambisonics */
const MP4_Box_t *p_SA3D = MP4_BoxGet(p_sample, "SA3D");
if (p_SA3D && BOXDATA(p_SA3D))
p_track->fmt.audio.channel_type = AUDIO_CHANNEL_TYPE_AMBISONICS;
/* Late fixes */ /* Late fixes */
if ( p_soun->i_qt_version == 0 && p_track->fmt.i_codec == VLC_CODEC_QCELP ) if ( p_soun->i_qt_version == 0 && p_track->fmt.i_codec == VLC_CODEC_QCELP )
{ {
......
...@@ -4119,6 +4119,23 @@ static int MP4_ReadBox_pnot( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -4119,6 +4119,23 @@ static int MP4_ReadBox_pnot( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 ); MP4_READBOX_EXIT( 1 );
} }
static int MP4_ReadBox_SA3D( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_SA3D_t, NULL );
uint8_t i_version;
MP4_GET1BYTE( i_version );
if ( i_version != 0 )
MP4_READBOX_EXIT( 0 );
MP4_GET1BYTE( p_box->data.p_SA3D->i_ambisonic_type );
MP4_GET4BYTES( p_box->data.p_SA3D->i_ambisonic_order );
MP4_GET1BYTE( p_box->data.p_SA3D->i_ambisonic_channel_ordering );
MP4_GET1BYTE( p_box->data.p_SA3D->i_ambisonic_normalization );
MP4_GET4BYTES( p_box->data.p_SA3D->i_num_channels );
MP4_READBOX_EXIT( 1 );
}
/* For generic */ /* For generic */
static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box )
{ {
...@@ -4561,6 +4578,9 @@ static const struct ...@@ -4561,6 +4578,9 @@ static const struct
{ ATOM_equi, MP4_ReadBox_equi, ATOM_proj }, { ATOM_equi, MP4_ReadBox_equi, ATOM_proj },
{ ATOM_cbmp, MP4_ReadBox_cbmp, ATOM_proj }, { ATOM_cbmp, MP4_ReadBox_cbmp, ATOM_proj },
/* Ambisonics */
{ ATOM_SA3D, MP4_ReadBox_SA3D, 0 },
/* Last entry */ /* Last entry */
{ 0, MP4_ReadBox_default, 0 } { 0, MP4_ReadBox_default, 0 }
}; };
......
...@@ -383,6 +383,8 @@ typedef int64_t stime_t; ...@@ -383,6 +383,8 @@ typedef int64_t stime_t;
#define ATOM_SDLN VLC_FOURCC( 'S', 'D', 'L', 'N' ) #define ATOM_SDLN VLC_FOURCC( 'S', 'D', 'L', 'N' )
#define ATOM_vndr VLC_FOURCC( 'v', 'n', 'd', 'r' ) #define ATOM_vndr VLC_FOURCC( 'v', 'n', 'd', 'r' )
#define ATOM_SA3D VLC_FOURCC( 'S', 'A', '3', 'D' )
#define HANDLER_mdta VLC_FOURCC('m', 'd', 't', 'a') #define HANDLER_mdta VLC_FOURCC('m', 'd', 't', 'a')
#define HANDLER_mdir VLC_FOURCC('m', 'd', 'i', 'r') #define HANDLER_mdir VLC_FOURCC('m', 'd', 'i', 'r')
#define HANDLER_ID32 ATOM_ID32 #define HANDLER_ID32 ATOM_ID32
...@@ -1611,6 +1613,15 @@ typedef struct ...@@ -1611,6 +1613,15 @@ typedef struct
uint32_t i_padding; uint32_t i_padding;
} MP4_Box_data_cbmp_t; } MP4_Box_data_cbmp_t;
typedef struct
{
uint8_t i_ambisonic_type;
uint32_t i_ambisonic_order;
uint8_t i_ambisonic_channel_ordering;
uint8_t i_ambisonic_normalization;
uint32_t i_num_channels;
} MP4_Box_data_SA3D_t;
/* /*
typedef struct MP4_Box_data__s typedef struct MP4_Box_data__s
{ {
...@@ -1722,6 +1733,7 @@ typedef union MP4_Box_data_s ...@@ -1722,6 +1733,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_prhd_t *p_prhd; MP4_Box_data_prhd_t *p_prhd;
MP4_Box_data_equi_t *p_equi; MP4_Box_data_equi_t *p_equi;
MP4_Box_data_cbmp_t *p_cbmp; MP4_Box_data_cbmp_t *p_cbmp;
MP4_Box_data_SA3D_t *p_SA3D;
/* for generic handlers */ /* for generic handlers */
MP4_Box_data_binary_t *p_binary; MP4_Box_data_binary_t *p_binary;
......
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