summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-08-01 00:49:08 -0300
committerJames Almer <jamrial@gmail.com>2019-08-24 22:41:58 -0300
commitd1409fe952822f46a5367aa6ec436f5849c757da (patch)
tree29c8f1cac766fe85fa287f3734a0c0b7b3939af9 /libavformat/mov.c
parentc300fe13b6294f6386803feff685b52b3571656c (diff)
avformat/mov: add demuxing support for Dolby TrueHD streams
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 24de5429d1..8a4cdc4b43 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -49,6 +49,7 @@
#include "libavcodec/ac3tab.h"
#include "libavcodec/flac.h"
#include "libavcodec/mpegaudiodecheader.h"
+#include "libavcodec/mlp_parse.h"
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
@@ -6683,6 +6684,38 @@ static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
+static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+ AVStream *st;
+ unsigned format_info;
+ int channel_assignment, channel_assignment1, channel_assignment2;
+ int ratebits;
+
+ if (c->fc->nb_streams < 1)
+ return 0;
+ st = c->fc->streams[c->fc->nb_streams-1];
+
+ if (atom.size < 10)
+ return AVERROR_INVALIDDATA;
+
+ format_info = avio_rb32(pb);
+
+ ratebits = (format_info >> 28) & 0xF;
+ channel_assignment1 = (format_info >> 15) & 0x1F;
+ channel_assignment2 = format_info & 0x1FFF;
+ if (channel_assignment2)
+ channel_assignment = channel_assignment2;
+ else
+ channel_assignment = channel_assignment1;
+
+ st->codecpar->frame_size = 40 << (ratebits & 0x7);
+ st->codecpar->sample_rate = mlp_samplerate(ratebits);
+ st->codecpar->channels = truehd_channels(channel_assignment);
+ st->codecpar->channel_layout = truehd_layout(channel_assignment);
+
+ return 0;
+}
+
static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('A','C','L','R'), mov_read_aclr },
{ MKTAG('A','P','R','G'), mov_read_avid },
@@ -6771,6 +6804,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('s','t','3','d'), mov_read_st3d }, /* stereoscopic 3D video box */
{ MKTAG('s','v','3','d'), mov_read_sv3d }, /* spherical video box */
{ MKTAG('d','O','p','s'), mov_read_dops },
+{ MKTAG('d','m','l','p'), mov_read_dmlp },
{ MKTAG('S','m','D','m'), mov_read_smdm },
{ MKTAG('C','o','L','L'), mov_read_coll },
{ MKTAG('v','p','c','C'), mov_read_vpcc },