Mark truncated packets as corrupt in av_get_packet.

Manually remove that flag again for formats that read an arbitrary
amount of data and thus truncation is not an error.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This commit is contained in:
Reimar Döffinger 2012-04-30 22:58:27 +02:00
parent 75f847aa6b
commit 7effbee66c
9 changed files with 12 additions and 0 deletions

View File

@ -322,6 +322,8 @@ static int aiff_read_packet(AVFormatContext *s,
if (res < 0)
return res;
if (size >= st->codec->block_align)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* Only one stream in an AIFF file */
pkt->stream_index = 0;
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;

View File

@ -76,6 +76,7 @@ static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
return 0;
}

View File

@ -187,6 +187,7 @@ static int au_read_packet(AVFormatContext *s,
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
if (ret < 0)
return ret;
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last

View File

@ -175,6 +175,7 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
ret= av_get_packet(s->pb, pkt, size);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret <= 0) {
if(ret<0)

View File

@ -36,6 +36,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
ret= av_get_packet(s->pb, pkt, size);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret < 0)
return ret;

View File

@ -80,6 +80,7 @@ static int rso_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last packet */

View File

@ -133,6 +133,7 @@ static int sol_read_packet(AVFormatContext *s,
ret= av_get_packet(s->pb, pkt, MAX_SIZE);
if (ret < 0)
return ret;
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last

View File

@ -138,6 +138,7 @@ static int sox_read_packet(AVFormatContext *s,
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return AVERROR(EIO);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
pkt->size = ret;

View File

@ -297,6 +297,7 @@ int ffio_limit(AVIOContext *s, int size)
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
int orig_size = size;
size= ffio_limit(s, size);
ret= av_new_packet(pkt, size);
@ -311,6 +312,8 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
av_free_packet(pkt);
else
av_shrink_packet(pkt, ret);
if (pkt->size < orig_size)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
return ret;
}