# HG changeset patch # User michael # Date 1120034461 0 # Node ID 09108466b7d0f2829d049dbf26133c46b8d9ece1 # Parent 930e56f92c571646ea885e2ffd3792436f824c19 off by 1 error bugfix avoid adding duplicate global headers to the bitstream diff -r 930e56f92c57 -r 09108466b7d0 parser.c --- a/parser.c Tue Jun 28 22:46:36 2005 +0000 +++ b/parser.c Wed Jun 29 08:41:01 2005 +0000 @@ -142,13 +142,17 @@ return index; } +/** + * + * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed + */ int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe){ if(s && s->parser->split){ - if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) && !(avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){ + if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){ int i= s->parser->split(avctx, buf, buf_size); buf += i; buf_size -= i; @@ -166,7 +170,7 @@ *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); - memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size); + memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); return 1; } } @@ -456,7 +460,7 @@ for(i=0; i= 0x100) - return i-4; + return i-3; } return 0; } @@ -548,7 +552,7 @@ for(i=0; i