Mercurial > libavcodec.hg
comparison parser.c @ 1614:6c82ef97d3e6 libavcodec
also parse extradata for MPEG4
| author | bellard |
|---|---|
| date | Mon, 10 Nov 2003 18:33:58 +0000 |
| parents | 0279c6c61f11 |
| children | 27a272442d6b |
comparison
equal
deleted
inserted
replaced
| 1613:0279c6c61f11 | 1614:6c82ef97d3e6 |
|---|---|
| 112 | 112 |
| 113 /* MPEG2 specific */ | 113 /* MPEG2 specific */ |
| 114 int frame_rate; | 114 int frame_rate; |
| 115 int progressive_sequence; | 115 int progressive_sequence; |
| 116 int width, height; | 116 int width, height; |
| 117 | |
| 117 /* XXX: suppress that, needed by MPEG4 */ | 118 /* XXX: suppress that, needed by MPEG4 */ |
| 118 MpegEncContext *enc; | 119 MpegEncContext *enc; |
| 120 int first_picture; | |
| 119 } ParseContext1; | 121 } ParseContext1; |
| 120 | 122 |
| 121 /** | 123 /** |
| 122 * combines the (truncated) bitstream to a complete frame | 124 * combines the (truncated) bitstream to a complete frame |
| 123 * @returns -1 if no complete frame could be created | 125 * @returns -1 if no complete frame could be created |
| 437 MpegEncContext *s = pc->enc; | 439 MpegEncContext *s = pc->enc; |
| 438 GetBitContext gb1, *gb = &gb1; | 440 GetBitContext gb1, *gb = &gb1; |
| 439 int ret; | 441 int ret; |
| 440 | 442 |
| 441 s->avctx = avctx; | 443 s->avctx = avctx; |
| 444 s->current_picture_ptr = &s->current_picture; | |
| 445 | |
| 446 if (avctx->extradata_size && pc->first_picture){ | |
| 447 init_get_bits(gb, avctx->extradata, avctx->extradata_size*8); | |
| 448 ret = ff_mpeg4_decode_picture_header(s, gb); | |
| 449 } | |
| 450 | |
| 442 init_get_bits(gb, buf, 8 * buf_size); | 451 init_get_bits(gb, buf, 8 * buf_size); |
| 443 ret = ff_mpeg4_decode_picture_header(s, gb); | 452 ret = ff_mpeg4_decode_picture_header(s, gb); |
| 444 if (s->width) { | 453 if (s->width) { |
| 445 avctx->width = s->width; | 454 avctx->width = s->width; |
| 446 avctx->height = s->height; | 455 avctx->height = s->height; |
| 447 } | 456 } |
| 457 pc->first_picture = 0; | |
| 448 return ret; | 458 return ret; |
| 449 } | 459 } |
| 450 | 460 |
| 451 int mpeg4video_parse_init(AVCodecParserContext *s) | 461 int mpeg4video_parse_init(AVCodecParserContext *s) |
| 452 { | 462 { |
| 453 ParseContext1 *pc = s->priv_data; | 463 ParseContext1 *pc = s->priv_data; |
| 464 | |
| 454 pc->enc = av_mallocz(sizeof(MpegEncContext)); | 465 pc->enc = av_mallocz(sizeof(MpegEncContext)); |
| 455 if (!pc->enc) | 466 if (!pc->enc) |
| 456 return -1; | 467 return -1; |
| 468 pc->first_picture = 1; | |
| 457 return 0; | 469 return 0; |
| 458 } | 470 } |
| 459 | 471 |
| 460 static int mpeg4video_parse(AVCodecParserContext *s, | 472 static int mpeg4video_parse(AVCodecParserContext *s, |
| 461 AVCodecContext *avctx, | 473 AVCodecContext *avctx, |
