annotate apc.c @ 1991:999e085b50eb libavformat

sane indention (no more 3 statements on one line...)
author michael
date Sat, 07 Apr 2007 22:41:45 +0000
parents e7a4bc0aa0fe
children 1a3c9056982a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1990
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
1 /*
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
2 * CRYO APC audio format demuxer
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
3 * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com>
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
4 *
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
5 * This file is part of FFmpeg.
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
6 *
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
11 *
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
15 * Lesser General Public License for more details.
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
16 *
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
20 */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
21
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
22 #include "avformat.h"
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
23 #include "string.h"
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
24
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
25 static int apc_probe(AVProbeData *p)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
26 {
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
27 if (p->buf_size < 8)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
28 return 0;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
29
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
30 if (!strncmp(p->buf, "CRYO_APC", 8))
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
31 return AVPROBE_SCORE_MAX;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
32
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
33 return 0;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
34 }
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
35
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
36 static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
37 {
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
38 ByteIOContext *pb = &s->pb;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
39 AVStream *st;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
40
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
41 get_le32(pb); /* CRYO */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
42 get_le32(pb); /* _APC */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
43 get_le32(pb); /* 1.20 */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
44
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
45 st = av_new_stream(s, 0);
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
46 if (!st)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
47 return AVERROR_NOMEM;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
48
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
49 st->codec->codec_type = CODEC_TYPE_AUDIO;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
50 st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
51
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
52 get_le32(pb); /* number of samples */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
53 st->codec->sample_rate = get_le32(pb);
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
54
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
55 st->codec->extradata_size = 2 * 4;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
56 st->codec->extradata = av_malloc(st->codec->extradata_size +
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
57 FF_INPUT_BUFFER_PADDING_SIZE);
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
58 if (!st->codec->extradata)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
59 return AVERROR_NOMEM;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
60
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
61 /* initial predictor values for adpcm decoder */
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
62 get_buffer(pb, st->codec->extradata, 2 * 4);
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
63
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
64 st->codec->channels = 1;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
65 if (get_le32(pb))
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
66 st->codec->channels = 2;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
67
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
68 st->codec->bits_per_sample = 4;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
69 st->codec->bit_rate = st->codec->bits_per_sample * st->codec->channels
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
70 * st->codec->sample_rate;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
71 st->codec->block_align = 1;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
72
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
73 return 0;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
74 }
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
75
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
76 #define MAX_READ_SIZE 4096
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
77
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
78 static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
79 {
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
80 if (av_get_packet(&s->pb, pkt, MAX_READ_SIZE) <= 0)
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
81 return AVERROR_IO;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
82 pkt->stream_index = 0;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
83 return 0;
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
84 }
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
85
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
86 AVInputFormat apc_demuxer = {
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
87 "apc",
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
88 "CRYO APC format",
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
89 0,
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
90 apc_probe,
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
91 apc_read_header,
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
92 apc_read_packet,
e7a4bc0aa0fe CRYO APC demuxer
diego
parents:
diff changeset
93 };