# HG changeset patch # User bellard # Date 1071499237 0 # Node ID 13169235c3064cc756c6f32599441caae4162cb8 # Parent 61cebcb5a9979c61a08d2b8cff59a6c9f5ecb9cc added End Of File handling to return last picture for MPEG1/2/4 diff -r 61cebcb5a997 -r 13169235c306 parser.c --- a/parser.c Mon Dec 15 09:21:28 2003 +0000 +++ b/parser.c Mon Dec 15 14:40:37 2003 +0000 @@ -63,12 +63,22 @@ return s; } +/* NOTE: buf_size == 0 is used to signal EOF so that the last frame + can be returned if necessary */ int av_parser_parse(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { int index; + uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; + + if (buf_size == 0) { + /* padding is always necessary even if EOF, so we add it here */ + memset(dummy_buf, 0, sizeof(dummy_buf)); + buf = dummy_buf; + } + /* WARNING: the returned index can be negative */ index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); /* update the file pointer */ @@ -201,6 +211,9 @@ } if(pc->frame_start_found){ + /* EOF considered as end of frame */ + if (buf_size == 0) + return 0; for(; iframe_start_found=0; - pc->state=-1; - return i-3; + /* EOF considered as end of frame */ + if (buf_size == 0) + return 0; + for(; iframe_start_found=0; + pc->state=-1; + return i-3; + } } - } } pc->frame_start_found= vop_found; pc->state= state;