Mercurial > libavformat.hg
annotate eacdata.c @ 5926:e4080988d1b2 libavformat
Another uninitialized value.
See http://tranquillity.ath.cx/clang/2010-03-30-1/report-e6KUTb.html#EndPath
author | rbultje |
---|---|
date | Fri, 02 Apr 2010 14:58:55 +0000 |
parents | 536e5527c1e0 |
children | 178de7695c6c |
rev | line source |
---|---|
2701 | 1 /* |
2 * Electronic Arts .cdata file Demuxer | |
3 * Copyright (c) 2007 Peter Ross | |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
4331
49c1d3b27727
Use full internal pathname in doxygen @file directives.
diego
parents:
3424
diff
changeset
|
23 * @file libavformat/eacdata.c |
2701 | 24 * Electronic Arts cdata Format Demuxer |
5508 | 25 * by Peter Ross (pross@xvid.org) |
2701 | 26 * |
27 * Technical details here: | |
28 * http://wiki.multimedia.cx/index.php?title=EA_Command_And_Conquer_3_Audio_Codec | |
29 */ | |
30 | |
31 #include "avformat.h" | |
32 | |
33 typedef struct { | |
34 unsigned int channels; | |
35 unsigned int audio_pts; | |
36 } CdataDemuxContext; | |
37 | |
38 static int cdata_probe(AVProbeData *p) | |
39 { | |
40 const uint8_t *b = p->buf; | |
41 | |
42 if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C)) | |
43 return AVPROBE_SCORE_MAX/8; | |
44 return 0; | |
45 } | |
46 | |
47 static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) | |
48 { | |
49 CdataDemuxContext *cdata = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2701
diff
changeset
|
50 ByteIOContext *pb = s->pb; |
2701 | 51 unsigned int sample_rate, header; |
52 AVStream *st; | |
53 | |
54 header = get_be16(pb); | |
55 switch (header) { | |
56 case 0x0400: cdata->channels = 1; break; | |
57 case 0x0404: cdata->channels = 2; break; | |
58 case 0x040C: cdata->channels = 4; break; | |
59 default: | |
60 av_log(s, AV_LOG_INFO, "unknown header 0x%04x\n", header); | |
61 return -1; | |
62 }; | |
63 | |
64 sample_rate = get_be16(pb); | |
65 url_fskip(pb, 12); | |
66 | |
67 st = av_new_stream(s, 0); | |
68 if (!st) | |
69 return AVERROR(ENOMEM); | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5897
diff
changeset
|
70 st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
2701 | 71 st->codec->codec_tag = 0; /* no fourcc */ |
72 st->codec->codec_id = CODEC_ID_ADPCM_EA_XAS; | |
73 st->codec->channels = cdata->channels; | |
74 st->codec->sample_rate = sample_rate; | |
75 av_set_pts_info(st, 64, 1, sample_rate); | |
76 | |
77 cdata->audio_pts = 0; | |
78 return 0; | |
79 } | |
80 | |
81 static int cdata_read_packet(AVFormatContext *s, AVPacket *pkt) | |
82 { | |
83 CdataDemuxContext *cdata = s->priv_data; | |
84 int packet_size = 76*cdata->channels; | |
85 | |
5897
d7f41380f52c
eacdata: fix a memleak, return partial packets and use proper return values.
reimar
parents:
5508
diff
changeset
|
86 int ret = av_get_packet(s->pb, pkt, packet_size); |
d7f41380f52c
eacdata: fix a memleak, return partial packets and use proper return values.
reimar
parents:
5508
diff
changeset
|
87 if (ret < 0) |
d7f41380f52c
eacdata: fix a memleak, return partial packets and use proper return values.
reimar
parents:
5508
diff
changeset
|
88 return ret; |
2701 | 89 pkt->pts = cdata->audio_pts++; |
5897
d7f41380f52c
eacdata: fix a memleak, return partial packets and use proper return values.
reimar
parents:
5508
diff
changeset
|
90 return 0; |
2701 | 91 } |
92 | |
93 AVInputFormat ea_cdata_demuxer = { | |
94 "ea_cdata", | |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
2771
diff
changeset
|
95 NULL_IF_CONFIG_SMALL("Electronic Arts cdata"), |
2701 | 96 sizeof(CdataDemuxContext), |
97 cdata_probe, | |
98 cdata_read_header, | |
99 cdata_read_packet, | |
100 .extensions = "cdata", | |
101 }; |