Mercurial > libavcodec.hg
diff mpegvideo.c @ 1218:358bbc952e27 libavcodec
10l (returning negative number of consumed bytes if the first startcode of a frame was split between 2 buffers)
author | michaelni |
---|---|
date | Sun, 27 Apr 2003 01:11:26 +0000 |
parents | 9182f5e70e9b |
children | ca979193f8e1 |
line wrap: on
line diff
--- a/mpegvideo.c Fri Apr 25 20:03:17 2003 +0000 +++ b/mpegvideo.c Sun Apr 27 01:11:26 2003 +0000 @@ -2770,17 +2770,33 @@ */ int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size){ ParseContext *pc= &s->parse_context; - + +#if 0 + if(pc->overread){ + printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); + printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); + } +#endif + + /* copy overreaded byes from last frame into buffer */ + for(; pc->overread>0; pc->overread--){ + pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; + } + pc->last_index= pc->index; - if(next==-1){ + /* copy into buffer end return */ + if(next == END_NOT_FOUND){ pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(&pc->buffer[pc->index], *buf, *buf_size); pc->index += *buf_size; return -1; } - + + pc->overread_index= pc->index + next; + + /* append to buffer */ if(pc->index){ pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); @@ -2790,6 +2806,19 @@ *buf_size= pc->last_index + next; } + /* store overread bytes */ + for(;next < 0; next++){ + pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next]; + pc->overread++; + } + +#if 0 + if(pc->overread){ + printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); + printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); + } +#endif + return 0; }