Mercurial > libavformat.hg
annotate flacdec.c @ 4649:fab2e46a5b1a libavformat
Mark pos_min and pos_max variables as av_uninit to work around false
positive uninitialized variable warnings.
author | diego |
---|---|
date | Thu, 05 Mar 2009 19:15:14 +0000 |
parents | 259725e31ef1 |
children | 478a7c56266a |
rev | line source |
---|---|
885 | 1 /* |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
2 * Raw FLAC demuxer |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4206
diff
changeset
|
3 * Copyright (c) 2001 Fabrice Bellard |
0 | 4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
0 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
0 | 11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
0 | 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 | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1245
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 20 */ |
3286 | 21 |
0 | 22 #include "avformat.h" |
2545
213268d7594e
move unrelated functions declarations out of allformats.h
aurel
parents:
2368
diff
changeset
|
23 #include "raw.h" |
4254 | 24 #include "id3v2.h" |
0 | 25 |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
26 static int flac_read_header(AVFormatContext *s, |
3268
319c36da904b
set demuxers .value and use common audio_read_header function
bcoudurier
parents:
3238
diff
changeset
|
27 AVFormatParameters *ap) |
63 | 28 { |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
29 uint8_t buf[ID3v2_HEADER_SIZE]; |
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
30 int ret; |
3268
319c36da904b
set demuxers .value and use common audio_read_header function
bcoudurier
parents:
3238
diff
changeset
|
31 AVStream *st = av_new_stream(s, 0); |
686
e2687b784c3a
shorten decoder by (Jeff Muizelaar <jrmuizel gmail com>)
michael
parents:
637
diff
changeset
|
32 if (!st) |
2273
7eb456c4ed8a
Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents:
2231
diff
changeset
|
33 return AVERROR(ENOMEM); |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
814
diff
changeset
|
34 st->codec->codec_type = CODEC_TYPE_AUDIO; |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
35 st->codec->codec_id = CODEC_ID_FLAC; |
2023 | 36 st->need_parsing = AVSTREAM_PARSE_FULL; |
931 | 37 /* the parameters will be extracted from the compressed bitstream */ |
4285
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
38 |
4612 | 39 /* skip ID3v2 header if found */ |
40 ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); | |
41 if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) { | |
42 int len = ff_id3v2_tag_len(buf); | |
43 url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR); | |
44 } else { | |
45 url_fseek(s->pb, 0, SEEK_SET); | |
46 } | |
0 | 47 return 0; |
48 } | |
4548
2c9ebc4029ae
add raw demuxer for Chinese AVS elementary streams
stefang
parents:
4510
diff
changeset
|
49 |
2365 | 50 static int flac_probe(AVProbeData *p) |
51 { | |
4285
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
52 uint8_t *bufptr = p->buf; |
4292
0e275ee37217
Check buffer is inside what is passed when probing for flac.
benoit
parents:
4285
diff
changeset
|
53 uint8_t *end = p->buf + p->buf_size; |
4285
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
54 |
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
55 if(ff_id3v2_match(bufptr)) |
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
56 bufptr += ff_id3v2_tag_len(bufptr); |
d8803d0a4274
Handle ID3v2 tags in raw FLAC streams by skipping them.
jbr
parents:
4254
diff
changeset
|
57 |
4292
0e275ee37217
Check buffer is inside what is passed when probing for flac.
benoit
parents:
4285
diff
changeset
|
58 if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0; |
4293 | 59 else return AVPROBE_SCORE_MAX/2; |
2365 | 60 } |
61 | |
3546
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
62 AVInputFormat flac_demuxer = { |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
63 "flac", |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
64 NULL_IF_CONFIG_SMALL("raw FLAC"), |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
65 0, |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
66 flac_probe, |
4610
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
67 flac_read_header, |
41542d2edcf4
Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents:
4577
diff
changeset
|
68 ff_raw_read_partial_packet, |
1756 | 69 .flags= AVFMT_GENERIC_INDEX, |
3546
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
70 .extensions = "flac", |
45c3d2b2b2fb
Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents:
3545
diff
changeset
|
71 .value = CODEC_ID_FLAC, |
931 | 72 }; |