Commit 81f052cb authored by Justin Ruggles's avatar Justin Ruggles

Separate the raw FLAC demuxer from raw.c and put in a new file,

flacdec.c.

Originally committed as revision 17660 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2d243fb3
...@@ -247,6 +247,7 @@ Muxers/Demuxers: ...@@ -247,6 +247,7 @@ Muxers/Demuxers:
dv.c Roman Shaposhnik dv.c Roman Shaposhnik
dxa.c Kostya Shishkov dxa.c Kostya Shishkov
ffm* Baptiste Coudurier ffm* Baptiste Coudurier
flac* Justin Ruggles
flic.c Mike Melanson flic.c Mike Melanson
flvdec.c, flvenc.c Michael Niedermayer flvdec.c, flvenc.c Michael Niedermayer
gxf.c Reimar Doeffinger gxf.c Reimar Doeffinger
......
...@@ -53,7 +53,7 @@ OBJS-$(CONFIG_EAC3_DEMUXER) += raw.o id3v2.o ...@@ -53,7 +53,7 @@ OBJS-$(CONFIG_EAC3_DEMUXER) += raw.o id3v2.o
OBJS-$(CONFIG_EAC3_MUXER) += raw.o OBJS-$(CONFIG_EAC3_MUXER) += raw.o
OBJS-$(CONFIG_FFM_DEMUXER) += ffmdec.o OBJS-$(CONFIG_FFM_DEMUXER) += ffmdec.o
OBJS-$(CONFIG_FFM_MUXER) += ffmenc.o OBJS-$(CONFIG_FFM_MUXER) += ffmenc.o
OBJS-$(CONFIG_FLAC_DEMUXER) += raw.o id3v2.o OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o raw.o id3v2.o
OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o OBJS-$(CONFIG_FLAC_MUXER) += flacenc.o
OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o
OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o
......
/*
* Raw FLAC demuxer
* Copyright (c) 2001 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "raw.h"
#include "id3v2.h"
static int flac_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
uint8_t buf[ID3v2_HEADER_SIZE];
int ret;
AVStream *st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL;
/* the parameters will be extracted from the compressed bitstream */
/* skip ID3v2 header if found */
ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) {
int len = ff_id3v2_tag_len(buf);
url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR);
} else {
url_fseek(s->pb, 0, SEEK_SET);
}
return 0;
}
static int flac_probe(AVProbeData *p)
{
uint8_t *bufptr = p->buf;
uint8_t *end = p->buf + p->buf_size;
if(ff_id3v2_match(bufptr))
bufptr += ff_id3v2_tag_len(bufptr);
if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
else return AVPROBE_SCORE_MAX/2;
}
AVInputFormat flac_demuxer = {
"flac",
NULL_IF_CONFIG_SMALL("raw FLAC"),
0,
flac_probe,
flac_read_header,
ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "flac",
.value = CODEC_ID_FLAC,
};
...@@ -130,7 +130,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -130,7 +130,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
} }
static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
{ {
int ret, size; int ret, size;
...@@ -258,17 +258,6 @@ static int audio_read_header(AVFormatContext *s, ...@@ -258,17 +258,6 @@ static int audio_read_header(AVFormatContext *s,
st->need_parsing = AVSTREAM_PARSE_FULL; st->need_parsing = AVSTREAM_PARSE_FULL;
/* the parameters will be extracted from the compressed bitstream */ /* the parameters will be extracted from the compressed bitstream */
if(st->codec->codec_id == CODEC_ID_FLAC) {
/* skip ID3v2 header if found */
uint8_t buf[ID3v2_HEADER_SIZE];
int ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) {
int len = ff_id3v2_tag_len(buf);
url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR);
} else {
url_fseek(s->pb, 0, SEEK_SET);
}
}
return 0; return 0;
} }
...@@ -593,20 +582,6 @@ static int eac3_probe(AVProbeData *p) ...@@ -593,20 +582,6 @@ static int eac3_probe(AVProbeData *p)
} }
#endif #endif
#if CONFIG_FLAC_DEMUXER
static int flac_probe(AVProbeData *p)
{
uint8_t *bufptr = p->buf;
uint8_t *end = p->buf + p->buf_size;
if(ff_id3v2_match(bufptr))
bufptr += ff_id3v2_tag_len(bufptr);
if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
else return AVPROBE_SCORE_MAX/2;
}
#endif
#if CONFIG_AAC_DEMUXER #if CONFIG_AAC_DEMUXER
static int adts_aac_probe(AVProbeData *p) static int adts_aac_probe(AVProbeData *p)
{ {
...@@ -655,7 +630,7 @@ AVInputFormat aac_demuxer = { ...@@ -655,7 +630,7 @@ AVInputFormat aac_demuxer = {
0, 0,
adts_aac_probe, adts_aac_probe,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "aac", .extensions = "aac",
.value = CODEC_ID_AAC, .value = CODEC_ID_AAC,
...@@ -669,7 +644,7 @@ AVInputFormat ac3_demuxer = { ...@@ -669,7 +644,7 @@ AVInputFormat ac3_demuxer = {
0, 0,
ac3_probe, ac3_probe,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "ac3", .extensions = "ac3",
.value = CODEC_ID_AC3, .value = CODEC_ID_AC3,
...@@ -698,7 +673,7 @@ AVInputFormat dirac_demuxer = { ...@@ -698,7 +673,7 @@ AVInputFormat dirac_demuxer = {
0, 0,
dirac_probe, dirac_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.value = CODEC_ID_DIRAC, .value = CODEC_ID_DIRAC,
}; };
...@@ -726,7 +701,7 @@ AVInputFormat dnxhd_demuxer = { ...@@ -726,7 +701,7 @@ AVInputFormat dnxhd_demuxer = {
0, 0,
dnxhd_probe, dnxhd_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.value = CODEC_ID_DNXHD, .value = CODEC_ID_DNXHD,
}; };
...@@ -754,7 +729,7 @@ AVInputFormat dts_demuxer = { ...@@ -754,7 +729,7 @@ AVInputFormat dts_demuxer = {
0, 0,
dts_probe, dts_probe,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "dts", .extensions = "dts",
.value = CODEC_ID_DTS, .value = CODEC_ID_DTS,
...@@ -783,7 +758,7 @@ AVInputFormat eac3_demuxer = { ...@@ -783,7 +758,7 @@ AVInputFormat eac3_demuxer = {
0, 0,
eac3_probe, eac3_probe,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "eac3", .extensions = "eac3",
.value = CODEC_ID_EAC3, .value = CODEC_ID_EAC3,
...@@ -805,20 +780,6 @@ AVOutputFormat eac3_muxer = { ...@@ -805,20 +780,6 @@ AVOutputFormat eac3_muxer = {
}; };
#endif #endif
#if CONFIG_FLAC_DEMUXER
AVInputFormat flac_demuxer = {
"flac",
NULL_IF_CONFIG_SMALL("raw FLAC"),
0,
flac_probe,
audio_read_header,
raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "flac",
.value = CODEC_ID_FLAC,
};
#endif
#if CONFIG_GSM_DEMUXER #if CONFIG_GSM_DEMUXER
AVInputFormat gsm_demuxer = { AVInputFormat gsm_demuxer = {
"gsm", "gsm",
...@@ -826,7 +787,7 @@ AVInputFormat gsm_demuxer = { ...@@ -826,7 +787,7 @@ AVInputFormat gsm_demuxer = {
0, 0,
NULL, NULL,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "gsm", .extensions = "gsm",
.value = CODEC_ID_GSM, .value = CODEC_ID_GSM,
...@@ -840,7 +801,7 @@ AVInputFormat h261_demuxer = { ...@@ -840,7 +801,7 @@ AVInputFormat h261_demuxer = {
0, 0,
h261_probe, h261_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "h261", .extensions = "h261",
.value = CODEC_ID_H261, .value = CODEC_ID_H261,
...@@ -869,7 +830,7 @@ AVInputFormat h263_demuxer = { ...@@ -869,7 +830,7 @@ AVInputFormat h263_demuxer = {
0, 0,
h263_probe, h263_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
// .extensions = "h263", //FIXME remove after writing mpeg4_probe // .extensions = "h263", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_H263, .value = CODEC_ID_H263,
...@@ -898,7 +859,7 @@ AVInputFormat h264_demuxer = { ...@@ -898,7 +859,7 @@ AVInputFormat h264_demuxer = {
0, 0,
h264_probe, h264_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_H264, .value = CODEC_ID_H264,
...@@ -941,7 +902,7 @@ AVInputFormat m4v_demuxer = { ...@@ -941,7 +902,7 @@ AVInputFormat m4v_demuxer = {
0, 0,
mpeg4video_probe, /** probing for MPEG-4 data */ mpeg4video_probe, /** probing for MPEG-4 data */
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "m4v", .extensions = "m4v",
.value = CODEC_ID_MPEG4, .value = CODEC_ID_MPEG4,
...@@ -970,7 +931,7 @@ AVInputFormat mjpeg_demuxer = { ...@@ -970,7 +931,7 @@ AVInputFormat mjpeg_demuxer = {
0, 0,
NULL, NULL,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "mjpg,mjpeg", .extensions = "mjpg,mjpeg",
.value = CODEC_ID_MJPEG, .value = CODEC_ID_MJPEG,
...@@ -999,7 +960,7 @@ AVInputFormat mlp_demuxer = { ...@@ -999,7 +960,7 @@ AVInputFormat mlp_demuxer = {
0, 0,
NULL, NULL,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "mlp", .extensions = "mlp",
.value = CODEC_ID_MLP, .value = CODEC_ID_MLP,
...@@ -1043,7 +1004,7 @@ AVInputFormat mpegvideo_demuxer = { ...@@ -1043,7 +1004,7 @@ AVInputFormat mpegvideo_demuxer = {
0, 0,
mpegvideo_probe, mpegvideo_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.value = CODEC_ID_MPEG1VIDEO, .value = CODEC_ID_MPEG1VIDEO,
}; };
...@@ -1056,7 +1017,7 @@ AVInputFormat cavsvideo_demuxer = { ...@@ -1056,7 +1017,7 @@ AVInputFormat cavsvideo_demuxer = {
0, 0,
cavsvideo_probe, cavsvideo_probe,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.value = CODEC_ID_CAVS, .value = CODEC_ID_CAVS,
}; };
...@@ -1132,7 +1093,7 @@ AVInputFormat shorten_demuxer = { ...@@ -1132,7 +1093,7 @@ AVInputFormat shorten_demuxer = {
0, 0,
NULL, NULL,
audio_read_header, audio_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX, .flags= AVFMT_GENERIC_INDEX,
.extensions = "shn", .extensions = "shn",
.value = CODEC_ID_SHORTEN, .value = CODEC_ID_SHORTEN,
...@@ -1146,7 +1107,7 @@ AVInputFormat vc1_demuxer = { ...@@ -1146,7 +1107,7 @@ AVInputFormat vc1_demuxer = {
0, 0,
NULL /* vc1_probe */, NULL /* vc1_probe */,
video_read_header, video_read_header,
raw_read_partial_packet, ff_raw_read_partial_packet,
.extensions = "vc1", .extensions = "vc1",
.value = CODEC_ID_VC1, .value = CODEC_ID_VC1,
}; };
......
...@@ -27,4 +27,6 @@ ...@@ -27,4 +27,6 @@
int pcm_read_seek(AVFormatContext *s, int pcm_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp, int flags); int stream_index, int64_t timestamp, int flags);
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt);
#endif /* AVFORMAT_RAW_H */ #endif /* AVFORMAT_RAW_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment