Browse code

avformat: add wve demuxer

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

Paul B Mahol authored on 2015/10/19 07:03:10
Showing 5 changed files
... ...
@@ -20,8 +20,9 @@ version <next>:
20 20
 - selectivecolor filter
21 21
 - extensive native AAC encoder improvements
22 22
 - ADPCM PSX decoder
23
-- genh, vag, ads & svag demuxer
23
+- genh, vag, ads, msf & svag demuxer
24 24
 - zscale filter
25
+- wve demuxer
25 26
 
26 27
 
27 28
 version 2.8:
... ...
@@ -481,6 +481,7 @@ OBJS-$(CONFIG_WTV_DEMUXER)               += wtvdec.o wtv_common.o asf.o \
481 481
 OBJS-$(CONFIG_WTV_MUXER)                 += wtvenc.o wtv_common.o \
482 482
                                             mpegtsenc.o asf.o
483 483
 OBJS-$(CONFIG_WV_DEMUXER)                += wvdec.o wv.o apetag.o img2.o
484
+OBJS-$(CONFIG_WVE_DEMUXER)               += wvedec.o pcm.o
484 485
 OBJS-$(CONFIG_WV_MUXER)                  += wvenc.o wv.o apetag.o img2.o
485 486
 OBJS-$(CONFIG_XA_DEMUXER)                += xa.o
486 487
 OBJS-$(CONFIG_XBIN_DEMUXER)              += bintext.o sauce.o
... ...
@@ -331,6 +331,7 @@ void av_register_all(void)
331 331
     REGISTER_DEMUXER (WSAUD,            wsaud);
332 332
     REGISTER_DEMUXER (WSVQA,            wsvqa);
333 333
     REGISTER_MUXDEMUX(WTV,              wtv);
334
+    REGISTER_DEMUXER (WVE,              wve);
334 335
     REGISTER_MUXDEMUX(WV,               wv);
335 336
     REGISTER_DEMUXER (XA,               xa);
336 337
     REGISTER_DEMUXER (XBIN,             xbin);
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavutil/version.h"
31 31
 
32 32
 #define LIBAVFORMAT_VERSION_MAJOR  57
33
-#define LIBAVFORMAT_VERSION_MINOR   9
33
+#define LIBAVFORMAT_VERSION_MINOR  10
34 34
 #define LIBAVFORMAT_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 37
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+/*
1
+ * Copyright (c) 2015 Paul B Mahol
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include "avformat.h"
21
+#include "internal.h"
22
+#include "pcm.h"
23
+
24
+static int wve_probe(AVProbeData *p)
25
+{
26
+    if (memcmp(p->buf, "ALawSoundFile**\0\017\020", 18) ||
27
+        memcmp(p->buf + 22, "\0\0\0\1\0\0\0\0\0\0", 10))
28
+        return 0;
29
+    return AVPROBE_SCORE_MAX;
30
+}
31
+
32
+static int wve_read_header(AVFormatContext *s)
33
+{
34
+    AVStream *st;
35
+
36
+    st = avformat_new_stream(s, NULL);
37
+    if (!st)
38
+        return AVERROR(ENOMEM);
39
+
40
+    avio_skip(s->pb, 18);
41
+    st->duration           = avio_rb32(s->pb);
42
+    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
43
+    st->codec->codec_id    = AV_CODEC_ID_PCM_ALAW;
44
+    st->codec->sample_rate = 8000;
45
+    st->codec->channels    = 1;
46
+    st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
47
+    st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
48
+    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
49
+    avio_skip(s->pb, 10);
50
+
51
+    return 0;
52
+}
53
+
54
+AVInputFormat ff_wve_demuxer = {
55
+    .name           = "wve",
56
+    .long_name      = NULL_IF_CONFIG_SMALL("Psion 3 audio"),
57
+    .read_probe     = wve_probe,
58
+    .read_header    = wve_read_header,
59
+    .read_packet    = ff_pcm_read_packet,
60
+    .read_seek      = ff_pcm_read_seek,
61
+};