aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2001-09-15 22:44:44 +0000
committerFabrice Bellard <fabrice@bellard.org>2001-09-15 22:44:44 +0000
commit2e93e3aaae6e56c5f774474046734ace2a4d78d7 (patch)
treea755a11e2f4fbd4806783669457ee21102084dc1
parent9dbf9389772781b245d849a695bd9318750174e6 (diff)
downloadffmpeg-2e93e3aaae6e56c5f774474046734ace2a4d78d7.tar.gz
fixed raw read for eof
Originally committed as revision 121 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libav/raw.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/libav/raw.c b/libav/raw.c
index 7e4965e9ef..f0d0c86c75 100644
--- a/libav/raw.c
+++ b/libav/raw.c
@@ -84,27 +84,25 @@ static int raw_read_header(AVFormatContext *s,
return 0;
}
-#define MIN_SIZE 1024
+#define RAW_PACKET_SIZE 1024
int raw_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- int packet_size, n, ret;
+ int ret;
- if (url_feof(&s->pb))
- return -EIO;
-
- packet_size = url_get_packet_size(&s->pb);
- n = MIN_SIZE / packet_size;
- if (n <= 0)
- n = 1;
- if (av_new_packet(pkt, n * packet_size) < 0)
+ if (av_new_packet(pkt, RAW_PACKET_SIZE) < 0)
return -EIO;
pkt->stream_index = 0;
- ret = get_buffer(&s->pb, pkt->data, pkt->size);
- if (ret < 0)
+ ret = get_buffer(&s->pb, pkt->data, RAW_PACKET_SIZE);
+ if (ret <= 0) {
av_free_packet(pkt);
+ return -EIO;
+ }
+ /* note: we need to modify the packet size here to handle the last
+ packet */
+ pkt->size = ret;
return ret;
}