comparison parser.c @ 4912:5fc99f2a111b libavcodec

move mpeg4video_parser in it's own file
author aurel
date Sat, 05 May 2007 17:59:37 +0000
parents 40f3a7f2b1fd
children b7bde71aa752
comparison
equal deleted inserted replaced
4911:b6a4f6c5623c 4912:5fc99f2a111b
295 av_free(pc1->pc.buffer); 295 av_free(pc1->pc.buffer);
296 av_free(pc1->enc); 296 av_free(pc1->enc);
297 } 297 }
298 298
299 /*************************/ 299 /*************************/
300
301 #ifdef CONFIG_MPEG4VIDEO_PARSER
302 /* used by parser */
303 /* XXX: make it use less memory */
304 static int av_mpeg4_decode_header(AVCodecParserContext *s1,
305 AVCodecContext *avctx,
306 const uint8_t *buf, int buf_size)
307 {
308 ParseContext1 *pc = s1->priv_data;
309 MpegEncContext *s = pc->enc;
310 GetBitContext gb1, *gb = &gb1;
311 int ret;
312
313 s->avctx = avctx;
314 s->current_picture_ptr = &s->current_picture;
315
316 if (avctx->extradata_size && pc->first_picture){
317 init_get_bits(gb, avctx->extradata, avctx->extradata_size*8);
318 ret = ff_mpeg4_decode_picture_header(s, gb);
319 }
320
321 init_get_bits(gb, buf, 8 * buf_size);
322 ret = ff_mpeg4_decode_picture_header(s, gb);
323 if (s->width) {
324 avcodec_set_dimensions(avctx, s->width, s->height);
325 }
326 s1->pict_type= s->pict_type;
327 pc->first_picture = 0;
328 return ret;
329 }
330
331 static int mpeg4video_parse_init(AVCodecParserContext *s)
332 {
333 ParseContext1 *pc = s->priv_data;
334
335 pc->enc = av_mallocz(sizeof(MpegEncContext));
336 if (!pc->enc)
337 return -1;
338 pc->first_picture = 1;
339 return 0;
340 }
341
342 static int mpeg4video_parse(AVCodecParserContext *s,
343 AVCodecContext *avctx,
344 uint8_t **poutbuf, int *poutbuf_size,
345 const uint8_t *buf, int buf_size)
346 {
347 ParseContext *pc = s->priv_data;
348 int next;
349
350 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
351 next= buf_size;
352 }else{
353 next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
354
355 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
356 *poutbuf = NULL;
357 *poutbuf_size = 0;
358 return buf_size;
359 }
360 }
361 av_mpeg4_decode_header(s, avctx, buf, buf_size);
362
363 *poutbuf = (uint8_t *)buf;
364 *poutbuf_size = buf_size;
365 return next;
366 }
367 #endif
368 300
369 int ff_mpeg4video_split(AVCodecContext *avctx, 301 int ff_mpeg4video_split(AVCodecContext *avctx,
370 const uint8_t *buf, int buf_size) 302 const uint8_t *buf, int buf_size)
371 { 303 {
372 int i; 304 int i;
845 } 777 }
846 return buf_ptr - buf; 778 return buf_ptr - buf;
847 } 779 }
848 #endif /* CONFIG_AC3_PARSER || CONFIG_AAC_PARSER */ 780 #endif /* CONFIG_AC3_PARSER || CONFIG_AAC_PARSER */
849 781
850 #ifdef CONFIG_MPEG4VIDEO_PARSER
851 AVCodecParser mpeg4video_parser = {
852 { CODEC_ID_MPEG4 },
853 sizeof(ParseContext1),
854 mpeg4video_parse_init,
855 mpeg4video_parse,
856 ff_parse1_close,
857 ff_mpeg4video_split,
858 };
859 #endif
860 #ifdef CONFIG_MPEGAUDIO_PARSER 782 #ifdef CONFIG_MPEGAUDIO_PARSER
861 AVCodecParser mpegaudio_parser = { 783 AVCodecParser mpegaudio_parser = {
862 { CODEC_ID_MP2, CODEC_ID_MP3 }, 784 { CODEC_ID_MP2, CODEC_ID_MP3 },
863 sizeof(MpegAudioParseContext), 785 sizeof(MpegAudioParseContext),
864 mpegaudio_parse_init, 786 mpegaudio_parse_init,