History

yuv4mpeg: return proper error codes.

Fixes Bug 373.

Anton Khirnov committed 14 years ago

Commit d3a72be1 parent e4cbf751 file · +15 −7Browse files

Unified · Split

libavformat/yuv4mpeg.c+15−7
@@ -367,7 +367,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) · 366 unmodified lines
367367 {
368368 int i;
369369 char header[MAX_FRAME_HEADER+1];
370− int packet_size, width, height;
370+ int packet_size, width, height, ret;
371371 AVStream *st = s->streams[0];
372372 struct frame_attributes *s1 = s->priv_data;
373373
@@ -378,20 +378,28 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) · 4 unmodified lines
378378 break;
379379 }
380380 }
381− if (i == MAX_FRAME_HEADER)
382− return -1;
381+ if (s->pb->error)
382+ return s->pb->error;
383+ else if (s->pb->eof_reached)
384+ return AVERROR_EOF;
385+ else if (i == MAX_FRAME_HEADER)
386+ return AVERROR_INVALIDDATA;
387+
383388 if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
384− return -1;
389+ return AVERROR_INVALIDDATA;
385390
386391 width = st->codec->width;
387392 height = st->codec->height;
388393
389394 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
390395 if (packet_size < 0)
391− return -1;
396+ return packet_size;
392397
393− if (av_get_packet(s->pb, pkt, packet_size) != packet_size)
394− return AVERROR(EIO);
398+ ret = av_get_packet(s->pb, pkt, packet_size);
399+ if (ret < 0)
400+ return ret;
401+ else if (ret != packet_size)
402+ return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
395403
396404 if (st->codec->coded_frame) {
397405 st->codec->coded_frame->interlaced_frame = s1->interlaced_frame;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t