Browse code

avformat: add acm demuxer

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2015/10/31 01:45:33
Showing 6 changed files
... ...
@@ -29,6 +29,7 @@ version <next>:
29 29
 - vibrato filter
30 30
 - innoHeim/Rsupport Screen Capture Codec decoder
31 31
 - ADPCM AICA decoder
32
+- Interplay ACM demuxer and audio decoder
32 33
 
33 34
 
34 35
 version 2.8:
... ...
@@ -242,6 +242,8 @@ library:
242 242
     @tab Multimedia format used in game Heart Of Darkness.
243 243
 @item Apple HTTP Live Streaming @tab   @tab X
244 244
 @item Artworx Data Format       @tab   @tab X
245
+@item Interplay ACM             @tab   @tab X
246
+    @tab Audio only format used in some Interplay games.
245 247
 @item ADP                       @tab   @tab X
246 248
     @tab Audio format used on the Nintendo Gamecube.
247 249
 @item AFC                       @tab   @tab X
... ...
@@ -63,6 +63,7 @@ OBJS-$(CONFIG_AA_DEMUXER)                += aadec.o
63 63
 OBJS-$(CONFIG_AAC_DEMUXER)               += aacdec.o apetag.o img2.o rawdec.o
64 64
 OBJS-$(CONFIG_AC3_DEMUXER)               += ac3dec.o rawdec.o
65 65
 OBJS-$(CONFIG_AC3_MUXER)                 += rawenc.o
66
+OBJS-$(CONFIG_ACM_DEMUXER)               += acm.o rawdec.o
66 67
 OBJS-$(CONFIG_ACT_DEMUXER)               += act.o
67 68
 OBJS-$(CONFIG_ADF_DEMUXER)               += bintext.o sauce.o
68 69
 OBJS-$(CONFIG_ADP_DEMUXER)               += adp.o
69 70
new file mode 100644
... ...
@@ -0,0 +1,75 @@
0
+/*
1
+ * ACM demuxer
2
+ * Copyright (c) 2015 Paul B Mahol
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#include "libavutil/intreadwrite.h"
22
+#include "avformat.h"
23
+#include "rawdec.h"
24
+#include "internal.h"
25
+
26
+static int acm_probe(AVProbeData *p)
27
+{
28
+    if (AV_RB32(p->buf) != 0x97280301)
29
+        return 0;
30
+
31
+    return AVPROBE_SCORE_MAX / 3 * 2;
32
+}
33
+
34
+static int acm_read_header(AVFormatContext *s)
35
+{
36
+    AVStream *st;
37
+    int ret;
38
+
39
+    st = avformat_new_stream(s, NULL);
40
+    if (!st)
41
+        return AVERROR(ENOMEM);
42
+
43
+    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
44
+    st->codec->codec_id   = AV_CODEC_ID_INTERPLAY_ACM;
45
+
46
+    ff_alloc_extradata(st->codec, 14);
47
+    if (!st->codec->extradata)
48
+        return AVERROR(ENOMEM);
49
+    ret = avio_read(s->pb, st->codec->extradata, 14);
50
+    if (ret < 10)
51
+        return ret < 0 ? ret : AVERROR_EOF;
52
+
53
+    st->codec->channels    = AV_RL16(st->codec->extradata +  8);
54
+    st->codec->sample_rate = AV_RL16(st->codec->extradata + 10);
55
+    if (st->codec->channels <= 0 || st->codec->sample_rate <= 0)
56
+        return AVERROR_INVALIDDATA;
57
+    st->start_time         = 0;
58
+    st->duration           = AV_RL32(st->codec->extradata +  4) / st->codec->channels;
59
+    st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
60
+    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
61
+
62
+    return 0;
63
+}
64
+
65
+AVInputFormat ff_acm_demuxer = {
66
+    .name           = "acm",
67
+    .long_name      = NULL_IF_CONFIG_SMALL("Interplay ACM"),
68
+    .read_probe     = acm_probe,
69
+    .read_header    = acm_read_header,
70
+    .read_packet    = ff_raw_read_partial_packet,
71
+    .flags          = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
72
+    .extensions     = "acm",
73
+    .raw_codec_id   = AV_CODEC_ID_INTERPLAY_ACM,
74
+};
... ...
@@ -63,6 +63,7 @@ void av_register_all(void)
63 63
     REGISTER_DEMUXER (AA,               aa);
64 64
     REGISTER_DEMUXER (AAC,              aac);
65 65
     REGISTER_MUXDEMUX(AC3,              ac3);
66
+    REGISTER_DEMUXER (ACM,              acm);
66 67
     REGISTER_DEMUXER (ACT,              act);
67 68
     REGISTER_DEMUXER (ADF,              adf);
68 69
     REGISTER_DEMUXER (ADP,              adp);
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR  57
33
-#define LIBAVFORMAT_VERSION_MINOR  13
33
+#define LIBAVFORMAT_VERSION_MINOR  14
34 34
 #define LIBAVFORMAT_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \