[Ffmpeg-cvslog] r5537 - trunk/libavformat/wav.c
michael
subversion
Wed Jun 28 12:51:57 CEST 2006
Author: michael
Date: Wed Jun 28 12:51:56 2006
New Revision: 5537
Modified:
trunk/libavformat/wav.c
Log:
dont read over the end of a data chunk and at the end search for the next
Modified: trunk/libavformat/wav.c
==============================================================================
--- trunk/libavformat/wav.c (original)
+++ trunk/libavformat/wav.c Wed Jun 28 12:51:56 2006
@@ -203,6 +203,7 @@
#ifdef CONFIG_MUXERS
typedef struct {
offset_t data;
+ offset_t data_end;
} WAVContext;
static int wav_write_header(AVFormatContext *s)
@@ -304,6 +305,7 @@
unsigned int tag;
ByteIOContext *pb = &s->pb;
AVStream *st;
+ WAVContext *wav = s->priv_data;
/* check RIFF header */
tag = get_le32(pb);
@@ -331,6 +333,7 @@
size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
if (size < 0)
return -1;
+ wav->data_end= url_ftell(pb) + size;
return 0;
}
@@ -339,19 +342,30 @@
static int wav_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- int ret, size;
+ int ret, size, left;
AVStream *st;
+ WAVContext *wav = s->priv_data;
if (url_feof(&s->pb))
return AVERROR_IO;
st = s->streams[0];
+ left= wav->data_end - url_ftell(&s->pb);
+ if(left <= 0){
+ left = find_tag(&(s->pb), MKTAG('d', 'a', 't', 'a'));
+ if (left < 0) {
+ return AVERROR_IO;
+ }
+ wav->data_end= url_ftell(&s->pb) + left;
+ }
+
size = MAX_SIZE;
if (st->codec->block_align > 1) {
if (size < st->codec->block_align)
size = st->codec->block_align;
size = (size / st->codec->block_align) * st->codec->block_align;
}
+ size= FFMIN(size, left);
if (av_new_packet(pkt, size))
return AVERROR_IO;
pkt->stream_index = 0;
@@ -393,7 +407,7 @@
static AVInputFormat wav_iformat = {
"wav",
"wav format",
- 0,
+ sizeof(WAVContext),
wav_probe,
wav_read_header,
wav_read_packet,
More information about the ffmpeg-cvslog
mailing list