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
367{367{
368 int i;368 int i;
369 char header[MAX_FRAME_HEADER+1];369 char header[MAX_FRAME_HEADER+1];
370 int packet_size, width, height;370 int packet_size, width, height, ret;
371 AVStream *st = s->streams[0];371 AVStream *st = s->streams[0];
372 struct frame_attributes *s1 = s->priv_data;372 struct frame_attributes *s1 = s->priv_data;
373 373
@@ -378,20 +378,28 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) · 4 unmodified lines
378 break;378 break;
379 }379 }
380 }380 }
381 if (i == MAX_FRAME_HEADER)381 if (s->pb->error)
382 return -1;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
383 if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))388 if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
384 return -1;389 return AVERROR_INVALIDDATA;
385 390
386 width = st->codec->width;391 width = st->codec->width;
387 height = st->codec->height;392 height = st->codec->height;
388 393
389 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);394 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
390 if (packet_size < 0)395 if (packet_size < 0)
391 return -1;396 return packet_size;
392 397
393 if (av_get_packet(s->pb, pkt, packet_size) != packet_size)398 ret = av_get_packet(s->pb, pkt, packet_size);
394 return AVERROR(EIO);399 if (ret < 0)
400 return ret;
401 else if (ret != packet_size)
402 return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
395 403
396 if (st->codec->coded_frame) {404 if (st->codec->coded_frame) {
397 st->codec->coded_frame->interlaced_frame = s1->interlaced_frame;405 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