[FFmpeg-devel] [PATCH] avformat/matroskadec: return AVERROR(EIO) rather than AVERROR_EOF on parse error

James Almer jamrial at gmail.com
Sat Jul 23 17:26:09 EEST 2016


On 7/23/2016 5:50 AM, Nicolas George wrote:
> Le quintidi 5 thermidor, an CCXXIV, Sophia Wang a écrit :
>> Signed-off-by: Sophia Wang <skw at google.com>
>> ---
>>  libavformat/matroskadec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index f3d701f..c536605 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -3323,7 +3323,7 @@ static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt)
>>      while (matroska_deliver_packet(matroska, pkt)) {
>>          int64_t pos = avio_tell(matroska->ctx->pb);
>>          if (matroska->done)
>> -            return AVERROR_EOF;
>> +            return avio_feof(s->pb) ? AVERROR_EOF : AVERROR(EIO);
>>          if (matroska_parse_cluster(matroska) < 0)
>>              matroska_resync(matroska, pos);
>>      }
> 
> This does not seem correct. EIO means something (usually along the lines
> from "you should not unplug your USB stick while watching a file stored on
> it" to "get a new hard drive and hope your backups are up to date"), it is
> not a generic error when nothing else fits; there is AVERROR_UNKNOWN for
> that.

AVERROR(EIO) is used in a lot of demuxers to signal overreads because of
incomplete files, damaged seek tables, etc.

In any case, checking the return value of matroska_resync(matroska, pos)
may be the correct thing to do here instead, since that function is the
one that sets matroska->done to 1, then returns EOF.


More information about the ffmpeg-devel mailing list