Originally committed as revision 8656 to svn://svn.ffmpeg.org/ffmpeg/trunk
Anssi Hannula authored on 2007/04/08 06:34:18... | ... |
@@ -907,6 +907,8 @@ different game cutscenes repacked for use with ScummVM. |
907 | 907 |
@tab Used in the game Cyberia from Interplay. |
908 | 908 |
@item Bethsoft VID @tab @tab X |
909 | 909 |
@tab Used in some games from Bethesda Softworks. |
910 |
+@item CRYO APC @tab @tab X |
|
911 |
+@tab Audio format used in some games by CRYO Interactive Entertainment. |
|
910 | 912 |
@end multitable |
911 | 913 |
|
912 | 914 |
@code{X} means that encoding (resp. decoding) is supported. |
... | ... |
@@ -612,6 +612,12 @@ static int adpcm_decode_init(AVCodecContext * avctx) |
612 | 612 |
case CODEC_ID_ADPCM_CT: |
613 | 613 |
c->status[0].step = c->status[1].step = 511; |
614 | 614 |
break; |
615 |
+ case CODEC_ID_ADPCM_IMA_WS: |
|
616 |
+ if (avctx->extradata && avctx->extradata_size == 2 * 4) { |
|
617 |
+ c->status[0].predictor = AV_RL32(avctx->extradata); |
|
618 |
+ c->status[1].predictor = AV_RL32(avctx->extradata + 4); |
|
619 |
+ } |
|
620 |
+ break; |
|
615 | 621 |
default: |
616 | 622 |
break; |
617 | 623 |
} |
... | ... |
@@ -17,6 +17,7 @@ OBJS-$(CONFIG_AIFF_DEMUXER) += aiff.o riff.o |
17 | 17 |
OBJS-$(CONFIG_AIFF_MUXER) += aiff.o riff.o |
18 | 18 |
OBJS-$(CONFIG_AMR_DEMUXER) += amr.o |
19 | 19 |
OBJS-$(CONFIG_AMR_MUXER) += amr.o |
20 |
+OBJS-$(CONFIG_APC_DEMUXER) += apc.o |
|
20 | 21 |
OBJS-$(CONFIG_ASF_DEMUXER) += asf.o riff.o |
21 | 22 |
OBJS-$(CONFIG_ASF_MUXER) += asf-enc.o riff.o |
22 | 23 |
OBJS-$(CONFIG_ASF_STREAM_MUXER) += asf-enc.o riff.o |
... | ... |
@@ -49,6 +49,7 @@ void av_register_all(void) |
49 | 49 |
REGISTER_MUXER (ADTS, adts); |
50 | 50 |
REGISTER_MUXDEMUX(AIFF, aiff); |
51 | 51 |
REGISTER_MUXDEMUX(AMR, amr); |
52 |
+ REGISTER_DEMUXER (APC, apc); |
|
52 | 53 |
REGISTER_MUXDEMUX(ASF, asf); |
53 | 54 |
REGISTER_MUXER (ASF_STREAM, asf_stream); |
54 | 55 |
REGISTER_MUXDEMUX(AU, au); |
... | ... |
@@ -26,6 +26,7 @@ extern AVInputFormat aac_demuxer; |
26 | 26 |
extern AVInputFormat ac3_demuxer; |
27 | 27 |
extern AVInputFormat aiff_demuxer; |
28 | 28 |
extern AVInputFormat amr_demuxer; |
29 |
+extern AVInputFormat apc_demuxer; |
|
29 | 30 |
extern AVInputFormat asf_demuxer; |
30 | 31 |
extern AVInputFormat au_demuxer; |
31 | 32 |
extern AVInputFormat audio_demuxer; |
32 | 33 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,93 @@ |
0 |
+/* |
|
1 |
+ * CRYO APC audio format demuxer |
|
2 |
+ * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com> |
|
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 "avformat.h" |
|
22 |
+#include "string.h" |
|
23 |
+ |
|
24 |
+static int apc_probe(AVProbeData *p) |
|
25 |
+{ |
|
26 |
+ if (p->buf_size < 8) |
|
27 |
+ return 0; |
|
28 |
+ |
|
29 |
+ if (!strncmp(p->buf, "CRYO_APC", 8)) |
|
30 |
+ return AVPROBE_SCORE_MAX; |
|
31 |
+ |
|
32 |
+ return 0; |
|
33 |
+} |
|
34 |
+ |
|
35 |
+static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
36 |
+{ |
|
37 |
+ ByteIOContext *pb = &s->pb; |
|
38 |
+ AVStream *st; |
|
39 |
+ |
|
40 |
+ get_le32(pb); /* CRYO */ |
|
41 |
+ get_le32(pb); /* _APC */ |
|
42 |
+ get_le32(pb); /* 1.20 */ |
|
43 |
+ |
|
44 |
+ st = av_new_stream(s, 0); |
|
45 |
+ if (!st) |
|
46 |
+ return AVERROR_NOMEM; |
|
47 |
+ |
|
48 |
+ st->codec->codec_type = CODEC_TYPE_AUDIO; |
|
49 |
+ st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS; |
|
50 |
+ |
|
51 |
+ get_le32(pb); /* number of samples */ |
|
52 |
+ st->codec->sample_rate = get_le32(pb); |
|
53 |
+ |
|
54 |
+ st->codec->extradata_size = 2 * 4; |
|
55 |
+ st->codec->extradata = av_malloc(st->codec->extradata_size + |
|
56 |
+ FF_INPUT_BUFFER_PADDING_SIZE); |
|
57 |
+ if (!st->codec->extradata) |
|
58 |
+ return AVERROR_NOMEM; |
|
59 |
+ |
|
60 |
+ /* initial predictor values for adpcm decoder */ |
|
61 |
+ get_buffer(pb, st->codec->extradata, 2 * 4); |
|
62 |
+ |
|
63 |
+ st->codec->channels = 1; |
|
64 |
+ if (get_le32(pb)) |
|
65 |
+ st->codec->channels = 2; |
|
66 |
+ |
|
67 |
+ st->codec->bits_per_sample = 4; |
|
68 |
+ st->codec->bit_rate = st->codec->bits_per_sample * st->codec->channels |
|
69 |
+ * st->codec->sample_rate; |
|
70 |
+ st->codec->block_align = 1; |
|
71 |
+ |
|
72 |
+ return 0; |
|
73 |
+} |
|
74 |
+ |
|
75 |
+#define MAX_READ_SIZE 4096 |
|
76 |
+ |
|
77 |
+static int apc_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
78 |
+{ |
|
79 |
+ if (av_get_packet(&s->pb, pkt, MAX_READ_SIZE) <= 0) |
|
80 |
+ return AVERROR_IO; |
|
81 |
+ pkt->stream_index = 0; |
|
82 |
+ return 0; |
|
83 |
+} |
|
84 |
+ |
|
85 |
+AVInputFormat apc_demuxer = { |
|
86 |
+ "apc", |
|
87 |
+ "CRYO APC format", |
|
88 |
+ 0, |
|
89 |
+ apc_probe, |
|
90 |
+ apc_read_header, |
|
91 |
+ apc_read_packet, |
|
92 |
+}; |