summaryrefslogtreecommitdiff
path: root/libavformat/spdifdec.c
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2022-06-19 20:00:07 -0500
committerrcombs <rcombs@rcombs.me>2023-01-13 11:22:59 -0600
commitd3538dd293125e0a8d135ffe229c8b441345d833 (patch)
tree1a84e566eca73499a1773f1136d0c92a3173997a /libavformat/spdifdec.c
parent6161eacc748e255fee5af0e1d56845afc27b2e7f (diff)
downloadffmpeg-d3538dd293125e0a8d135ffe229c8b441345d833.tar.gz
lavf/spdifdec: support EAC3
Parsing should probably be enabled for all codecs, at least for headers, but e.g. the AAC parser produces 1-byte packets of zero padding with it, so I'm just enabling it for EAC3 for the moment.
Diffstat (limited to 'libavformat/spdifdec.c')
-rw-r--r--libavformat/spdifdec.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index 672133581a..7a6b77aae8 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -31,6 +31,7 @@
#include "libavcodec/adts_parser.h"
#include "avformat.h"
+#include "internal.h"
#include "spdif.h"
static int spdif_get_offset_and_codec(AVFormatContext *s,
@@ -93,6 +94,10 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
*offset = 8192;
*codec = AV_CODEC_ID_DTS;
break;
+ case IEC61937_EAC3:
+ *offset = 24576;
+ *codec = AV_CODEC_ID_EAC3;
+ break;
default:
if (s) { /* be silent during a probe */
avpriv_request_sample(s, "Data type 0x%04x in IEC 61937",
@@ -170,6 +175,16 @@ static int spdif_read_header(AVFormatContext *s)
return 0;
}
+static int spdif_get_pkt_size_bits(int type, int code)
+{
+ switch (type & 0xff) {
+ case IEC61937_EAC3:
+ return code << 3;
+ default:
+ return code;
+ }
+}
+
int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
@@ -185,7 +200,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
}
data_type = avio_rl16(pb);
- pkt_size_bits = avio_rl16(pb);
+ pkt_size_bits = spdif_get_pkt_size_bits(data_type, avio_rl16(pb));
if (pkt_size_bits % 16)
avpriv_request_sample(s, "Packet not ending at a 16-bit boundary");
@@ -218,6 +233,8 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
}
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = codec_id;
+ if (codec_id == AV_CODEC_ID_EAC3)
+ ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL;
} else if (codec_id != s->streams[0]->codecpar->codec_id) {
avpriv_report_missing_feature(s, "Codec change in IEC 61937");
return AVERROR_PATCHWELCOME;