mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
fixed raw read for eof
Originally committed as revision 121 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
9dbf938977
commit
2e93e3aaae
22
libav/raw.c
22
libav/raw.c
@ -84,27 +84,25 @@ static int raw_read_header(AVFormatContext *s,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MIN_SIZE 1024
|
#define RAW_PACKET_SIZE 1024
|
||||||
|
|
||||||
int raw_read_packet(AVFormatContext *s,
|
int raw_read_packet(AVFormatContext *s,
|
||||||
AVPacket *pkt)
|
AVPacket *pkt)
|
||||||
{
|
{
|
||||||
int packet_size, n, ret;
|
int ret;
|
||||||
|
|
||||||
if (url_feof(&s->pb))
|
if (av_new_packet(pkt, RAW_PACKET_SIZE) < 0)
|
||||||
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)
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
ret = get_buffer(&s->pb, pkt->data, pkt->size);
|
ret = get_buffer(&s->pb, pkt->data, RAW_PACKET_SIZE);
|
||||||
if (ret < 0)
|
if (ret <= 0) {
|
||||||
av_free_packet(pkt);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user