aboutsummaryrefslogtreecommitdiffstats
path: root/libav/wav.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2002-05-20 16:31:13 +0000
committerFabrice Bellard <fabrice@bellard.org>2002-05-20 16:31:13 +0000
commitc9a65ca8c306071b3c359b56a384a1594cd505df (patch)
treea33c4b156673f2c1404042501c1cebaae6a35457 /libav/wav.c
parentdb7f1f95acc050bb5ddf62b0008eab8c8305d369 (diff)
downloadffmpeg-c9a65ca8c306071b3c359b56a384a1594cd505df.tar.gz
converted to new API
Originally committed as revision 547 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libav/wav.c')
-rw-r--r--libav/wav.c56
1 files changed, 36 insertions, 20 deletions
diff --git a/libav/wav.c b/libav/wav.c
index a50d6f86f3..b634b977ce 100644
--- a/libav/wav.c
+++ b/libav/wav.c
@@ -110,16 +110,10 @@ typedef struct {
static int wav_write_header(AVFormatContext *s)
{
- WAVContext *wav;
+ WAVContext *wav = s->priv_data;
ByteIOContext *pb = &s->pb;
offset_t fmt;
- wav = av_malloc(sizeof(WAVContext));
- if (!wav)
- return -1;
- memset(wav, 0, sizeof(WAVContext));
- s->priv_data = wav;
-
put_tag(pb, "RIFF");
put_le32(pb, 0); /* file length */
put_tag(pb, "WAVE");
@@ -165,8 +159,6 @@ static int wav_write_trailer(AVFormatContext *s)
put_flush_packet(pb);
}
-
- av_free(wav);
return 0;
}
@@ -191,6 +183,20 @@ static int find_tag(ByteIOContext *pb, UINT32 tag1)
return size;
}
+static int wav_probe(AVProbeData *p)
+{
+ /* check file header */
+ if (p->buf_size <= 32)
+ return 0;
+ if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
+ p->buf[2] == 'F' && p->buf[3] == 'F' &&
+ p->buf[8] == 'W' && p->buf[9] == 'A' &&
+ p->buf[10] == 'V' && p->buf[11] == 'E')
+ return AVPROBE_SCORE_MAX;
+ else
+ return 0;
+}
+
/* wav input */
static int wav_read_header(AVFormatContext *s,
AVFormatParameters *ap)
@@ -233,14 +239,10 @@ static int wav_read_header(AVFormatContext *s,
return -1;
/* now we are ready: build format streams */
- st = av_malloc(sizeof(AVStream));
+ st = av_new_stream(s, 0);
if (!st)
- return -1;
- s->nb_streams = 1;
- s->streams[0] = st;
+ return AVERROR_NOMEM;
- st->id = 0;
-
st->codec.codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = id;
st->codec.codec_id = wav_codec_get_id(id, bps);
@@ -280,18 +282,32 @@ static int wav_read_close(AVFormatContext *s)
return 0;
}
-AVFormat wav_format = {
+static AVInputFormat wav_iformat = {
+ "wav",
+ "wav format",
+ 0,
+ wav_probe,
+ wav_read_header,
+ wav_read_packet,
+ wav_read_close,
+};
+
+static AVOutputFormat wav_oformat = {
"wav",
"wav format",
"audio/x-wav",
"wav",
+ sizeof(WAVContext),
CODEC_ID_PCM_S16LE,
CODEC_ID_NONE,
wav_write_header,
wav_write_packet,
wav_write_trailer,
-
- wav_read_header,
- wav_read_packet,
- wav_read_close,
};
+
+int wav_init(void)
+{
+ av_register_input_format(&wav_iformat);
+ av_register_output_format(&wav_oformat);
+ return 0;
+}