diff mbox

[FFmpeg-devel,v8,3/4] lavf/isom: support for demuxing and remuxing of MPEG-H 3D Audio in MP4

Message ID 20191212140204.25657-3-Yuki.Tsuchiya@sony.com
State New
Headers show

Commit Message

Yuki.Tsuchiya Dec. 12, 2019, 2:02 p.m. UTC
Implemented according to the specification at https://www.iso.org/standard/69561.html
The 'mhm1' sample entry is registered with MP4RA, which is defined as MHAS encapsulated single stream MPEG-H 3D Audio.
'MHAS' stands for MPEG-H audio stream, which contains encoded audio data and corresponds metadata for decoding.
This patch enables extracting the MHAS bitstream from MP4 and remuxing into MP4.

Signed-off-by: Yuki Tsuchiya <Yuki.Tsuchiya@sony.com>
---
 libavcodec/avcodec.h    | 1 +
 libavcodec/codec_desc.c | 7 +++++++
 libavcodec/version.h    | 4 ++--
 libavformat/isom.c      | 1 +
 libavformat/movenc.c    | 2 ++
 5 files changed, 13 insertions(+), 2 deletions(-)

Comments

James Almer Dec. 12, 2019, 3:57 p.m. UTC | #1
On 12/12/2019 11:02 AM, Yuki Tsuchiya wrote:
> Implemented according to the specification at https://www.iso.org/standard/69561.html
> The 'mhm1' sample entry is registered with MP4RA, which is defined as MHAS encapsulated single stream MPEG-H 3D Audio.
> 'MHAS' stands for MPEG-H audio stream, which contains encoded audio data and corresponds metadata for decoding.
> This patch enables extracting the MHAS bitstream from MP4 and remuxing into MP4.
> 
> Signed-off-by: Yuki Tsuchiya <Yuki.Tsuchiya@sony.com>
> ---
>  libavcodec/avcodec.h    | 1 +
>  libavcodec/codec_desc.c | 7 +++++++
>  libavcodec/version.h    | 4 ++--
>  libavformat/isom.c      | 1 +
>  libavformat/movenc.c    | 2 ++
>  5 files changed, 13 insertions(+), 2 deletions(-)

I split this in two patches (one for the new codec id, one for the
support in mp4) and pushed thanks.
diff mbox

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 735a3c2d76..119b32dc1f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -656,6 +656,7 @@  enum AVCodecID {
     AV_CODEC_ID_ATRAC9,
     AV_CODEC_ID_HCOM,
     AV_CODEC_ID_ACELP_KELVIN,
+    AV_CODEC_ID_MPEGH_3D_AUDIO,
 
     /* subtitle codecs */
     AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 3b0ffa0f5d..bdc1dacda4 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3016,6 +3016,13 @@  static const AVCodecDescriptor codec_descriptors[] = {
         .long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"),
         .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
     },
+    {
+        .id        = AV_CODEC_ID_MPEGH_3D_AUDIO,
+        .type      = AVMEDIA_TYPE_AUDIO,
+        .name      = "mpegh_3d_audio",
+        .long_name = NULL_IF_CONFIG_SMALL("MPEG-H 3D Audio"),
+        .props     = AV_CODEC_PROP_LOSSY,
+    },
 
     /* subtitle codecs */
     {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8b9c27378c..94bcbae2d6 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@ 
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  64
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MINOR  65
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavformat/isom.c b/libavformat/isom.c
index edd0d81063..824e811177 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -371,6 +371,7 @@  const AVCodecTag ff_codec_movaudio_tags[] = {
     { AV_CODEC_ID_FLAC,            MKTAG('f', 'L', 'a', 'C') }, /* nonstandard */
     { AV_CODEC_ID_TRUEHD,          MKTAG('m', 'l', 'p', 'a') }, /* mp4ra.org */
     { AV_CODEC_ID_OPUS,            MKTAG('O', 'p', 'u', 's') }, /* mp4ra.org */
+    { AV_CODEC_ID_MPEGH_3D_AUDIO,  MKTAG('m', 'h', 'm', '1') }, /* MPEG-H 3D Audio bitstream */
     { AV_CODEC_ID_NONE, 0 },
 };
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index dd144ae20a..8456bfac6d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2493,6 +2493,7 @@  static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext
     mov_write_stts_tag(pb, track);
     if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
          track->par->codec_id == AV_CODEC_ID_TRUEHD ||
+         track->par->codec_id == AV_CODEC_ID_MPEGH_3D_AUDIO ||
          track->par->codec_tag == MKTAG('r','t','p',' ')) &&
         track->has_keyframes && track->has_keyframes < track->entry)
         mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
@@ -6875,6 +6876,7 @@  const AVCodecTag codec_mp4_tags[] = {
     { AV_CODEC_ID_DVD_SUBTITLE, MKTAG('m', 'p', '4', 's') },
     { AV_CODEC_ID_MOV_TEXT    , MKTAG('t', 'x', '3', 'g') },
     { AV_CODEC_ID_BIN_DATA    , MKTAG('g', 'p', 'm', 'd') },
+    { AV_CODEC_ID_MPEGH_3D_AUDIO, MKTAG('m', 'h', 'm', '1') },
     { AV_CODEC_ID_NONE        ,    0 },
 };