1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

added End Of File handling to return last picture for MPEG1/2/4

Originally committed as revision 2614 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Fabrice Bellard 2003-12-15 14:40:37 +00:00
parent 5d43635e47
commit 6e45e92856

View File

@ -63,12 +63,22 @@ AVCodecParserContext *av_parser_init(int codec_id)
return s; 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, int av_parser_parse(AVCodecParserContext *s,
AVCodecContext *avctx, AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size, uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size) const uint8_t *buf, int buf_size)
{ {
int index; 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 */ /* WARNING: the returned index can be negative */
index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size);
/* update the file pointer */ /* update the file pointer */
@ -201,6 +211,9 @@ static int mpeg1_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_s
} }
if(pc->frame_start_found){ if(pc->frame_start_found){
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
for(; i<buf_size; i++){ for(; i<buf_size; i++){
state= (state<<8) | buf[i]; state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){ if((state&0xFFFFFF00) == 0x100){
@ -418,6 +431,9 @@ static int mpeg4_find_frame_end(ParseContext1 *pc,
} }
if(vop_found){ if(vop_found){
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
for(; i<buf_size; i++){ for(; i<buf_size; i++){
state= (state<<8) | buf[i]; state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){ if((state&0xFFFFFF00) == 0x100){