3
* Copyright (c) 2001 Fabrice Bellard
5
* This file is part of FFmpeg.
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.
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.
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
26
static int flac_read_header(AVFormatContext *s,
27
AVFormatParameters *ap)
29
uint8_t buf[ID3v2_HEADER_SIZE];
31
AVStream *st = av_new_stream(s, 0);
33
return AVERROR(ENOMEM);
34
st->codec->codec_type = CODEC_TYPE_AUDIO;
35
st->codec->codec_id = CODEC_ID_FLAC;
36
st->need_parsing = AVSTREAM_PARSE_FULL;
37
/* the parameters will be extracted from the compressed bitstream */
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);
45
url_fseek(s->pb, 0, SEEK_SET);
50
static int flac_probe(AVProbeData *p)
52
uint8_t *bufptr = p->buf;
53
uint8_t *end = p->buf + p->buf_size;
55
if(ff_id3v2_match(bufptr))
56
bufptr += ff_id3v2_tag_len(bufptr);
58
if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
59
else return AVPROBE_SCORE_MAX/2;
62
AVInputFormat flac_demuxer = {
64
NULL_IF_CONFIG_SMALL("raw FLAC"),
68
ff_raw_read_partial_packet,
69
.flags= AVFMT_GENERIC_INDEX,
71
.value = CODEC_ID_FLAC,