[vlc-commits] demux: mp4: read and save ambisonics metadata
Adrien Maglo
git at videolan.org
Wed Jul 19 18:59:46 CEST 2017
vlc | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Feb 27 12:20:27 2017 +0100| [45c2a47597802d256d911cfffcda68de023e0988] | committer: 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.md
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=45c2a47597802d256d911cfffcda68de023e0988
---
modules/demux/mp4/essetup.c | 5 +++++
modules/demux/mp4/libmp4.c | 20 ++++++++++++++++++++
modules/demux/mp4/libmp4.h | 12 ++++++++++++
3 files changed, 37 insertions(+)
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 74359a4022..f94cb1f88a 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -1183,6 +1183,11 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
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 */
if ( p_soun->i_qt_version == 0 && p_track->fmt.i_codec == VLC_CODEC_QCELP )
{
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index bd0feaedb3..0eeac770b0 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -4119,6 +4119,23 @@ static int MP4_ReadBox_pnot( stream_t *p_stream, MP4_Box_t *p_box )
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 */
static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box )
{
@@ -4561,6 +4578,9 @@ static const struct
{ ATOM_equi, MP4_ReadBox_equi, ATOM_proj },
{ ATOM_cbmp, MP4_ReadBox_cbmp, ATOM_proj },
+ /* Ambisonics */
+ { ATOM_SA3D, MP4_ReadBox_SA3D, 0 },
+
/* Last entry */
{ 0, MP4_ReadBox_default, 0 }
};
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index c37c22aea2..7d7285b4b2 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -383,6 +383,8 @@ typedef int64_t stime_t;
#define ATOM_SDLN VLC_FOURCC( 'S', 'D', 'L', 'N' )
#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_mdir VLC_FOURCC('m', 'd', 'i', 'r')
#define HANDLER_ID32 ATOM_ID32
@@ -1611,6 +1613,15 @@ typedef struct
uint32_t i_padding;
} 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
{
@@ -1722,6 +1733,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_prhd_t *p_prhd;
MP4_Box_data_equi_t *p_equi;
MP4_Box_data_cbmp_t *p_cbmp;
+ MP4_Box_data_SA3D_t *p_SA3D;
/* for generic handlers */
MP4_Box_data_binary_t *p_binary;
More information about the vlc-commits
mailing list