Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2012/11/04 03:09:46... | ... |
@@ -150,6 +150,8 @@ library: |
150 | 150 |
@item ASF @tab X @tab X |
151 | 151 |
@item AVI @tab X @tab X |
152 | 152 |
@item AVISynth @tab @tab X |
153 |
+@item AVR @tab @tab X |
|
154 |
+ @tab Audio format used on Mac. |
|
153 | 155 |
@item AVS @tab @tab X |
154 | 156 |
@tab Multimedia format used by the Creature Shock game. |
155 | 157 |
@item Beam Software SIFF @tab @tab X |
... | ... |
@@ -56,6 +56,7 @@ OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o |
56 | 56 |
OBJS-$(CONFIG_AVI_MUXER) += avienc.o |
57 | 57 |
OBJS-$(CONFIG_AVISYNTH) += avisynth.o |
58 | 58 |
OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o swf.o |
59 |
+OBJS-$(CONFIG_AVR_DEMUXER) += avr.o |
|
59 | 60 |
OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o |
60 | 61 |
OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o |
61 | 62 |
OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o |
... | ... |
@@ -69,6 +69,7 @@ void av_register_all(void) |
69 | 69 |
REGISTER_MUXDEMUX (AVI, avi); |
70 | 70 |
REGISTER_DEMUXER (AVISYNTH, avisynth); |
71 | 71 |
REGISTER_MUXER (AVM2, avm2); |
72 |
+ REGISTER_DEMUXER (AVR, avr); |
|
72 | 73 |
REGISTER_DEMUXER (AVS, avs); |
73 | 74 |
REGISTER_DEMUXER (BETHSOFTVID, bethsoftvid); |
74 | 75 |
REGISTER_DEMUXER (BFI, bfi); |
75 | 76 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,95 @@ |
0 |
+/* |
|
1 |
+ * AVR demuxer |
|
2 |
+ * Copyright (c) 2012 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 "internal.h" |
|
24 |
+#include "rawdec.h" |
|
25 |
+ |
|
26 |
+static int avr_probe(AVProbeData *p) |
|
27 |
+{ |
|
28 |
+ if (AV_RL32(p->buf) == MKTAG('2', 'B', 'I', 'T')) |
|
29 |
+ return AVPROBE_SCORE_MAX / 2; |
|
30 |
+ return 0; |
|
31 |
+} |
|
32 |
+ |
|
33 |
+static int avr_read_header(AVFormatContext *s) |
|
34 |
+{ |
|
35 |
+ uint16_t chan, sign, bps; |
|
36 |
+ AVStream *st; |
|
37 |
+ |
|
38 |
+ st = avformat_new_stream(s, NULL); |
|
39 |
+ if (!st) |
|
40 |
+ return AVERROR(ENOMEM); |
|
41 |
+ |
|
42 |
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
|
43 |
+ |
|
44 |
+ avio_skip(s->pb, 4); // magic |
|
45 |
+ avio_skip(s->pb, 8); // sample_name |
|
46 |
+ |
|
47 |
+ chan = avio_rb16(s->pb); |
|
48 |
+ if (!chan) { |
|
49 |
+ st->codec->channels = 1; |
|
50 |
+ } else if (chan == 0xFFFFu) { |
|
51 |
+ st->codec->channels = 2; |
|
52 |
+ } else { |
|
53 |
+ av_log_ask_for_sample(s, "unknown number of channels\n"); |
|
54 |
+ return AVERROR_PATCHWELCOME; |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ st->codec->bits_per_coded_sample = bps = avio_rb16(s->pb); |
|
58 |
+ |
|
59 |
+ sign = avio_rb16(s->pb); |
|
60 |
+ |
|
61 |
+ avio_skip(s->pb, 2); // loop |
|
62 |
+ avio_skip(s->pb, 2); // midi |
|
63 |
+ |
|
64 |
+ st->codec->sample_rate = avio_rb32(s->pb); |
|
65 |
+ avio_skip(s->pb, 4 * 3); |
|
66 |
+ avio_skip(s->pb, 2 * 3); |
|
67 |
+ avio_skip(s->pb, 20); |
|
68 |
+ avio_skip(s->pb, 64); |
|
69 |
+ |
|
70 |
+ if (!sign && bps == 8) { |
|
71 |
+ st->codec->codec_id = AV_CODEC_ID_PCM_U8; |
|
72 |
+ } else if (!sign && bps == 16) { |
|
73 |
+ st->codec->codec_id = AV_CODEC_ID_PCM_U16BE; |
|
74 |
+ } else if (sign == 0xFFFFu && bps == 8) { |
|
75 |
+ st->codec->codec_id = AV_CODEC_ID_PCM_S8; |
|
76 |
+ } else if (sign == 0xFFFFu && bps == 16) { |
|
77 |
+ st->codec->codec_id = AV_CODEC_ID_PCM_S16BE; |
|
78 |
+ } else { |
|
79 |
+ av_log_ask_for_sample(s, "unknown bits per sample\n"); |
|
80 |
+ return AVERROR_PATCHWELCOME; |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); |
|
84 |
+ return 0; |
|
85 |
+} |
|
86 |
+ |
|
87 |
+AVInputFormat ff_avr_demuxer = { |
|
88 |
+ .name = "avr", |
|
89 |
+ .long_name = NULL_IF_CONFIG_SMALL("Audio Visual Resarch (AVR)"), |
|
90 |
+ .read_probe = avr_probe, |
|
91 |
+ .read_header = avr_read_header, |
|
92 |
+ .read_packet = ff_raw_read_partial_packet, |
|
93 |
+ .extensions = "avr", |
|
94 |
+}; |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "libavutil/avutil.h" |
31 | 31 |
|
32 | 32 |
#define LIBAVFORMAT_VERSION_MAJOR 54 |
33 |
-#define LIBAVFORMAT_VERSION_MINOR 35 |
|
33 |
+#define LIBAVFORMAT_VERSION_MINOR 36 |
|
34 | 34 |
#define LIBAVFORMAT_VERSION_MICRO 100 |
35 | 35 |
|
36 | 36 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |