From fcc9a6282dd3c541055636ac49882d1639da251b Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 19 Jul 2005 20:30:38 +0000 Subject: here is cvs update people requested - somebody please check for gcc4 compatibility CVS patchset: 7668 CVS date: 2005/07/19 20:30:38 --- src/libffmpeg/libavcodec/parser.c | 68 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'src/libffmpeg/libavcodec/parser.c') diff --git a/src/libffmpeg/libavcodec/parser.c b/src/libffmpeg/libavcodec/parser.c index 93bbf87d1..280bb45f5 100644 --- a/src/libffmpeg/libavcodec/parser.c +++ b/src/libffmpeg/libavcodec/parser.c @@ -142,6 +142,42 @@ int av_parser_parse(AVCodecParserContext *s, 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)){ + int i= s->parser->split(avctx, buf, buf_size); + buf += i; + buf_size -= i; + } + } + + *poutbuf= buf; + *poutbuf_size= buf_size; + if(avctx->extradata){ + if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) + /*||(s->pict_type != I_TYPE && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/ + /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ + int size= buf_size + avctx->extradata_size; + *poutbuf_size= size; + *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + + memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); + memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + return 1; + } + } + + return 0; +} + void av_parser_close(AVCodecParserContext *s) { if (s->parser->parser_close) @@ -294,7 +330,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, int frame_rate_ext_n, frame_rate_ext_d; int picture_structure, top_field_first, repeat_first_field, progressive_frame; int horiz_size_ext, vert_size_ext, bit_rate_ext; - +//FIXME replace the crap with get_bits() s->repeat_pict = 0; buf_end = buf + buf_size; while (buf < buf_end) { @@ -415,6 +451,20 @@ static int mpegvideo_parse(AVCodecParserContext *s, return next; } +static int mpegvideo_split(AVCodecContext *avctx, + const uint8_t *buf, int buf_size) +{ + int i; + uint32_t state= -1; + + for(i=0; i= 0x100) + return i-3; + } + return 0; +} + void ff_parse_close(AVCodecParserContext *s) { ParseContext *pc = s->priv_data; @@ -493,6 +543,20 @@ static int mpeg4video_parse(AVCodecParserContext *s, return next; } +static int mpeg4video_split(AVCodecContext *avctx, + const uint8_t *buf, int buf_size) +{ + int i; + uint32_t state= -1; + + for(i=0; i