Mercurial > libavcodec.hg
comparison parser.c @ 2777:09108466b7d0 libavcodec
off by 1 error bugfix
avoid adding duplicate global headers to the bitstream
| author | michael |
|---|---|
| date | Wed, 29 Jun 2005 08:41:01 +0000 |
| parents | 1394b45a7bf4 |
| children | 45ccf6842c34 |
comparison
equal
deleted
inserted
replaced
| 2776:930e56f92c57 | 2777:09108466b7d0 |
|---|---|
| 140 index = 0; | 140 index = 0; |
| 141 s->cur_offset += index; | 141 s->cur_offset += index; |
| 142 return index; | 142 return index; |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** | |
| 146 * | |
| 147 * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed | |
| 148 */ | |
| 145 int av_parser_change(AVCodecParserContext *s, | 149 int av_parser_change(AVCodecParserContext *s, |
| 146 AVCodecContext *avctx, | 150 AVCodecContext *avctx, |
| 147 uint8_t **poutbuf, int *poutbuf_size, | 151 uint8_t **poutbuf, int *poutbuf_size, |
| 148 const uint8_t *buf, int buf_size, int keyframe){ | 152 const uint8_t *buf, int buf_size, int keyframe){ |
| 149 | 153 |
| 150 if(s && s->parser->split){ | 154 if(s && s->parser->split){ |
| 151 if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) && !(avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){ | 155 if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){ |
| 152 int i= s->parser->split(avctx, buf, buf_size); | 156 int i= s->parser->split(avctx, buf, buf_size); |
| 153 buf += i; | 157 buf += i; |
| 154 buf_size -= i; | 158 buf_size -= i; |
| 155 } | 159 } |
| 156 } | 160 } |
| 164 int size= buf_size + avctx->extradata_size; | 168 int size= buf_size + avctx->extradata_size; |
| 165 *poutbuf_size= size; | 169 *poutbuf_size= size; |
| 166 *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | 170 *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); |
| 167 | 171 |
| 168 memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); | 172 memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); |
| 169 memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size); | 173 memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
| 170 return 1; | 174 return 1; |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 | 177 |
| 174 return 0; | 178 return 0; |
| 454 uint32_t state= -1; | 458 uint32_t state= -1; |
| 455 | 459 |
| 456 for(i=0; i<buf_size; i++){ | 460 for(i=0; i<buf_size; i++){ |
| 457 state= (state<<8) | buf[i]; | 461 state= (state<<8) | buf[i]; |
| 458 if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100) | 462 if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100) |
| 459 return i-4; | 463 return i-3; |
| 460 } | 464 } |
| 461 return 0; | 465 return 0; |
| 462 } | 466 } |
| 463 | 467 |
| 464 void ff_parse_close(AVCodecParserContext *s) | 468 void ff_parse_close(AVCodecParserContext *s) |
| 546 uint32_t state= -1; | 550 uint32_t state= -1; |
| 547 | 551 |
| 548 for(i=0; i<buf_size; i++){ | 552 for(i=0; i<buf_size; i++){ |
| 549 state= (state<<8) | buf[i]; | 553 state= (state<<8) | buf[i]; |
| 550 if(state == 0x1B3 || state == 0x1B6) | 554 if(state == 0x1B3 || state == 0x1B6) |
| 551 return i-4; | 555 return i-3; |
| 552 } | 556 } |
| 553 return 0; | 557 return 0; |
| 554 } | 558 } |
| 555 | 559 |
| 556 /*************************/ | 560 /*************************/ |
