Mercurial > libavcodec.hg
annotate mpeg4video_parser.c @ 4949:845386be542c libavcodec
Add ff_ prefix to (externally) visible variables
author | kostya |
---|---|
date | Wed, 09 May 2007 16:59:46 +0000 |
parents | 0d1cc37d9430 |
children | 3fcb2f0d9ef1 |
rev | line source |
---|---|
4912 | 1 /* |
2 * MPEG4 Video frame extraction | |
3 * Copyright (c) 2003 Fabrice Bellard. | |
4 * Copyright (c) 2003 Michael Niedermayer. | |
5 * | |
6 * This file is part of FFmpeg. | |
7 * | |
8 * FFmpeg is free software; you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public | |
10 * License as published by the Free Software Foundation; either | |
11 * version 2.1 of the License, or (at your option) any later version. | |
12 * | |
13 * FFmpeg is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with FFmpeg; if not, write to the Free Software | |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
21 */ | |
22 | |
23 #include "parser.h" | |
24 #include "mpegvideo.h" | |
25 | |
26 | |
27 /* XXX: make it use less memory */ | |
28 static int av_mpeg4_decode_header(AVCodecParserContext *s1, | |
29 AVCodecContext *avctx, | |
30 const uint8_t *buf, int buf_size) | |
31 { | |
32 ParseContext1 *pc = s1->priv_data; | |
33 MpegEncContext *s = pc->enc; | |
34 GetBitContext gb1, *gb = &gb1; | |
35 int ret; | |
36 | |
37 s->avctx = avctx; | |
38 s->current_picture_ptr = &s->current_picture; | |
39 | |
40 if (avctx->extradata_size && pc->first_picture){ | |
41 init_get_bits(gb, avctx->extradata, avctx->extradata_size*8); | |
42 ret = ff_mpeg4_decode_picture_header(s, gb); | |
43 } | |
44 | |
45 init_get_bits(gb, buf, 8 * buf_size); | |
46 ret = ff_mpeg4_decode_picture_header(s, gb); | |
47 if (s->width) { | |
48 avcodec_set_dimensions(avctx, s->width, s->height); | |
49 } | |
50 s1->pict_type= s->pict_type; | |
51 pc->first_picture = 0; | |
52 return ret; | |
53 } | |
54 | |
55 static int mpeg4video_parse_init(AVCodecParserContext *s) | |
56 { | |
57 ParseContext1 *pc = s->priv_data; | |
58 | |
59 pc->enc = av_mallocz(sizeof(MpegEncContext)); | |
60 if (!pc->enc) | |
61 return -1; | |
62 pc->first_picture = 1; | |
63 return 0; | |
64 } | |
65 | |
66 static int mpeg4video_parse(AVCodecParserContext *s, | |
67 AVCodecContext *avctx, | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4912
diff
changeset
|
68 const uint8_t **poutbuf, int *poutbuf_size, |
4912 | 69 const uint8_t *buf, int buf_size) |
70 { | |
71 ParseContext *pc = s->priv_data; | |
72 int next; | |
73 | |
74 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ | |
75 next= buf_size; | |
76 }else{ | |
77 next= ff_mpeg4_find_frame_end(pc, buf, buf_size); | |
78 | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4912
diff
changeset
|
79 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
4912 | 80 *poutbuf = NULL; |
81 *poutbuf_size = 0; | |
82 return buf_size; | |
83 } | |
84 } | |
85 av_mpeg4_decode_header(s, avctx, buf, buf_size); | |
86 | |
4931
0d1cc37d9430
make some parser parameters const to avoid casting const to non-const
aurel
parents:
4912
diff
changeset
|
87 *poutbuf = buf; |
4912 | 88 *poutbuf_size = buf_size; |
89 return next; | |
90 } | |
91 | |
92 | |
93 AVCodecParser mpeg4video_parser = { | |
94 { CODEC_ID_MPEG4 }, | |
95 sizeof(ParseContext1), | |
96 mpeg4video_parse_init, | |
97 mpeg4video_parse, | |
98 ff_parse1_close, | |
99 ff_mpeg4video_split, | |
100 }; |