Mercurial > libavcodec.hg
annotate parser.c @ 3977:ebf01ad52879 libavcodec
10l
author | michael |
---|---|
date | Mon, 09 Oct 2006 21:21:10 +0000 |
parents | c8c591fe26f8 |
children | eddcc352c0dc |
rev | line source |
---|---|
1613 | 1 /* |
2 * Audio and Video frame extraction | |
3 * Copyright (c) 2003 Fabrice Bellard. | |
4 * Copyright (c) 2003 Michael Niedermayer. | |
5 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
1613 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
1613 | 12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
1613 | 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 | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3776
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1613 | 21 */ |
22 #include "avcodec.h" | |
23 #include "mpegvideo.h" | |
24 #include "mpegaudio.h" | |
25 | |
26 AVCodecParser *av_first_parser = NULL; | |
27 | |
28 void av_register_codec_parser(AVCodecParser *parser) | |
29 { | |
30 parser->next = av_first_parser; | |
31 av_first_parser = parser; | |
32 } | |
33 | |
34 AVCodecParserContext *av_parser_init(int codec_id) | |
35 { | |
36 AVCodecParserContext *s; | |
37 AVCodecParser *parser; | |
38 int ret; | |
2967 | 39 |
2486
f2a9559db6ac
10l (array gets padded with 0 which is CODEC_ID_NONE -> parsers claim to support CODEC_ID_NONE)
michael
parents:
2480
diff
changeset
|
40 if(codec_id == CODEC_ID_NONE) |
f2a9559db6ac
10l (array gets padded with 0 which is CODEC_ID_NONE -> parsers claim to support CODEC_ID_NONE)
michael
parents:
2480
diff
changeset
|
41 return NULL; |
1613 | 42 |
43 for(parser = av_first_parser; parser != NULL; parser = parser->next) { | |
44 if (parser->codec_ids[0] == codec_id || | |
45 parser->codec_ids[1] == codec_id || | |
2348 | 46 parser->codec_ids[2] == codec_id || |
47 parser->codec_ids[3] == codec_id || | |
48 parser->codec_ids[4] == codec_id) | |
1613 | 49 goto found; |
50 } | |
51 return NULL; | |
52 found: | |
53 s = av_mallocz(sizeof(AVCodecParserContext)); | |
54 if (!s) | |
55 return NULL; | |
56 s->parser = parser; | |
57 s->priv_data = av_mallocz(parser->priv_data_size); | |
58 if (!s->priv_data) { | |
59 av_free(s); | |
60 return NULL; | |
61 } | |
62 if (parser->parser_init) { | |
63 ret = parser->parser_init(s); | |
64 if (ret != 0) { | |
65 av_free(s->priv_data); | |
66 av_free(s); | |
67 return NULL; | |
68 } | |
69 } | |
2030 | 70 s->fetch_timestamp=1; |
1613 | 71 return s; |
72 } | |
73 | |
1694
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
74 /* NOTE: buf_size == 0 is used to signal EOF so that the last frame |
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
75 can be returned if necessary */ |
2967 | 76 int av_parser_parse(AVCodecParserContext *s, |
1613 | 77 AVCodecContext *avctx, |
2967 | 78 uint8_t **poutbuf, int *poutbuf_size, |
1696 | 79 const uint8_t *buf, int buf_size, |
80 int64_t pts, int64_t dts) | |
1613 | 81 { |
1696 | 82 int index, i, k; |
1694
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
83 uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; |
2967 | 84 |
1694
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
85 if (buf_size == 0) { |
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
86 /* padding is always necessary even if EOF, so we add it here */ |
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
87 memset(dummy_buf, 0, sizeof(dummy_buf)); |
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
88 buf = dummy_buf; |
1696 | 89 } else { |
90 /* add a new packet descriptor */ | |
91 k = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); | |
92 s->cur_frame_start_index = k; | |
93 s->cur_frame_offset[k] = s->cur_offset; | |
94 s->cur_frame_pts[k] = pts; | |
95 s->cur_frame_dts[k] = dts; | |
96 | |
97 /* fill first PTS/DTS */ | |
2030 | 98 if (s->fetch_timestamp){ |
99 s->fetch_timestamp=0; | |
1696 | 100 s->last_pts = pts; |
101 s->last_dts = dts; | |
2107 | 102 s->cur_frame_pts[k] = |
103 s->cur_frame_dts[k] = AV_NOPTS_VALUE; | |
1696 | 104 } |
1694
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
105 } |
13169235c306
added End Of File handling to return last picture for MPEG1/2/4
bellard
parents:
1681
diff
changeset
|
106 |
1613 | 107 /* WARNING: the returned index can be negative */ |
108 index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size); | |
2107 | 109 //av_log(NULL, AV_LOG_DEBUG, "parser: in:%lld, %lld, out:%lld, %lld, in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id); |
1613 | 110 /* update the file pointer */ |
111 if (*poutbuf_size) { | |
1696 | 112 /* fill the data for the current frame */ |
1613 | 113 s->frame_offset = s->last_frame_offset; |
1696 | 114 s->pts = s->last_pts; |
115 s->dts = s->last_dts; | |
2967 | 116 |
1696 | 117 /* offset of the next frame */ |
1613 | 118 s->last_frame_offset = s->cur_offset + index; |
1696 | 119 /* find the packet in which the new frame starts. It |
120 is tricky because of MPEG video start codes | |
121 which can begin in one packet and finish in | |
122 another packet. In the worst case, an MPEG | |
123 video start code could be in 4 different | |
124 packets. */ | |
125 k = s->cur_frame_start_index; | |
126 for(i = 0; i < AV_PARSER_PTS_NB; i++) { | |
127 if (s->last_frame_offset >= s->cur_frame_offset[k]) | |
128 break; | |
129 k = (k - 1) & (AV_PARSER_PTS_NB - 1); | |
130 } | |
2030 | 131 |
1696 | 132 s->last_pts = s->cur_frame_pts[k]; |
133 s->last_dts = s->cur_frame_dts[k]; | |
2967 | 134 |
2030 | 135 /* some parsers tell us the packet size even before seeing the first byte of the next packet, |
136 so the next pts/dts is in the next chunk */ | |
137 if(index == buf_size){ | |
138 s->fetch_timestamp=1; | |
139 } | |
1613 | 140 } |
141 if (index < 0) | |
142 index = 0; | |
143 s->cur_offset += index; | |
144 return index; | |
145 } | |
146 | |
2777 | 147 /** |
148 * | |
149 * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed | |
3421
b7826511f7b6
AVBitStreamFilter (some thingy which can modify the bitstream like add or remove global headers or change the headers or ...)
michael
parents:
3395
diff
changeset
|
150 * @deprecated use AVBitstreamFilter |
2777 | 151 */ |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
152 int av_parser_change(AVCodecParserContext *s, |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
153 AVCodecContext *avctx, |
2967 | 154 uint8_t **poutbuf, int *poutbuf_size, |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
155 const uint8_t *buf, int buf_size, int keyframe){ |
2967 | 156 |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
157 if(s && s->parser->split){ |
2777 | 158 if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){ |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
159 int i= s->parser->split(avctx, buf, buf_size); |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
160 buf += i; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
161 buf_size -= i; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
162 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
163 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
164 |
2864
95bac7109ff0
Kill some compiler warnings. Compiled code verified identical after changes.
mru
parents:
2846
diff
changeset
|
165 /* cast to avoid warning about discarding qualifiers */ |
95bac7109ff0
Kill some compiler warnings. Compiled code verified identical after changes.
mru
parents:
2846
diff
changeset
|
166 *poutbuf= (uint8_t *) buf; |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
167 *poutbuf_size= buf_size; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
168 if(avctx->extradata){ |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
169 if( (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
170 /*||(s->pict_type != I_TYPE && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/ |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
171 /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){ |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
172 int size= buf_size + avctx->extradata_size; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
173 *poutbuf_size= size; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
174 *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); |
2967 | 175 |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
176 memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); |
2777 | 177 memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
178 return 1; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
179 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
180 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
181 |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
182 return 0; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
183 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
184 |
1613 | 185 void av_parser_close(AVCodecParserContext *s) |
186 { | |
187 if (s->parser->parser_close) | |
188 s->parser->parser_close(s); | |
189 av_free(s->priv_data); | |
190 av_free(s); | |
191 } | |
192 | |
193 /*****************************************************/ | |
194 | |
195 //#define END_NOT_FOUND (-100) | |
196 | |
2979 | 197 #define PICTURE_START_CODE 0x00000100 |
198 #define SEQ_START_CODE 0x000001b3 | |
199 #define EXT_START_CODE 0x000001b5 | |
200 #define SLICE_MIN_START_CODE 0x00000101 | |
201 #define SLICE_MAX_START_CODE 0x000001af | |
1613 | 202 |
203 typedef struct ParseContext1{ | |
1988 | 204 ParseContext pc; |
205 /* XXX/FIXME PC1 vs. PC */ | |
1613 | 206 /* MPEG2 specific */ |
207 int frame_rate; | |
208 int progressive_sequence; | |
209 int width, height; | |
1614 | 210 |
1613 | 211 /* XXX: suppress that, needed by MPEG4 */ |
212 MpegEncContext *enc; | |
1614 | 213 int first_picture; |
1613 | 214 } ParseContext1; |
215 | |
216 /** | |
217 * combines the (truncated) bitstream to a complete frame | |
218 * @returns -1 if no complete frame could be created | |
219 */ | |
1988 | 220 int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size) |
1613 | 221 { |
222 #if 0 | |
223 if(pc->overread){ | |
224 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); | |
225 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); | |
226 } | |
227 #endif | |
228 | |
229 /* copy overreaded bytes from last frame into buffer */ | |
230 for(; pc->overread>0; pc->overread--){ | |
231 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; | |
232 } | |
2386 | 233 |
234 /* flush remaining if EOF */ | |
235 if(!*buf_size && next == END_NOT_FOUND){ | |
236 next= 0; | |
237 } | |
238 | |
1613 | 239 pc->last_index= pc->index; |
240 | |
241 /* copy into buffer end return */ | |
242 if(next == END_NOT_FOUND){ | |
243 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); | |
244 | |
245 memcpy(&pc->buffer[pc->index], *buf, *buf_size); | |
246 pc->index += *buf_size; | |
247 return -1; | |
248 } | |
249 | |
250 *buf_size= | |
251 pc->overread_index= pc->index + next; | |
2967 | 252 |
1613 | 253 /* append to buffer */ |
254 if(pc->index){ | |
255 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); | |
256 | |
257 memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); | |
258 pc->index = 0; | |
259 *buf= pc->buffer; | |
260 } | |
261 | |
262 /* store overread bytes */ | |
263 for(;next < 0; next++){ | |
264 pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next]; | |
265 pc->overread++; | |
266 } | |
267 | |
268 #if 0 | |
269 if(pc->overread){ | |
270 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); | |
271 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); | |
272 } | |
273 #endif | |
274 | |
275 return 0; | |
276 } | |
277 | |
278 /* XXX: merge with libavcodec ? */ | |
279 #define MPEG1_FRAME_RATE_BASE 1001 | |
280 | |
281 static const int frame_rate_tab[16] = { | |
2967 | 282 0, |
1613 | 283 24000, |
284 24024, | |
285 25025, | |
286 30000, | |
287 30030, | |
288 50050, | |
289 60000, | |
290 60060, | |
291 // Xing's 15fps: (9) | |
292 15015, | |
293 // libmpeg3's "Unofficial economy rates": (10-13) | |
294 5005, | |
295 10010, | |
296 12012, | |
297 15015, | |
298 // random, just to avoid segfault !never encode these | |
299 25025, | |
300 25025, | |
301 }; | |
302 | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
303 #ifdef CONFIG_MPEGVIDEO_PARSER |
2637 | 304 //FIXME move into mpeg12.c |
2967 | 305 static void mpegvideo_extract_headers(AVCodecParserContext *s, |
1613 | 306 AVCodecContext *avctx, |
307 const uint8_t *buf, int buf_size) | |
308 { | |
309 ParseContext1 *pc = s->priv_data; | |
310 const uint8_t *buf_end; | |
3776 | 311 uint32_t start_code; |
1613 | 312 int frame_rate_index, ext_type, bytes_left; |
313 int frame_rate_ext_n, frame_rate_ext_d; | |
2119 | 314 int picture_structure, top_field_first, repeat_first_field, progressive_frame; |
2539 | 315 int horiz_size_ext, vert_size_ext, bit_rate_ext; |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
316 //FIXME replace the crap with get_bits() |
1613 | 317 s->repeat_pict = 0; |
318 buf_end = buf + buf_size; | |
319 while (buf < buf_end) { | |
3086 | 320 start_code= -1; |
321 buf= ff_find_start_code(buf, buf_end, &start_code); | |
1613 | 322 bytes_left = buf_end - buf; |
323 switch(start_code) { | |
324 case PICTURE_START_CODE: | |
325 if (bytes_left >= 2) { | |
326 s->pict_type = (buf[1] >> 3) & 7; | |
327 } | |
328 break; | |
329 case SEQ_START_CODE: | |
2539 | 330 if (bytes_left >= 7) { |
2269 | 331 pc->width = (buf[0] << 4) | (buf[1] >> 4); |
332 pc->height = ((buf[1] & 0x0f) << 8) | buf[2]; | |
2270 | 333 avcodec_set_dimensions(avctx, pc->width, pc->height); |
1613 | 334 frame_rate_index = buf[3] & 0xf; |
2637 | 335 pc->frame_rate = avctx->time_base.den = frame_rate_tab[frame_rate_index]; |
336 avctx->time_base.num = MPEG1_FRAME_RATE_BASE; | |
2539 | 337 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; |
1681 | 338 avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
339 avctx->sub_id = 1; | |
1613 | 340 } |
341 break; | |
342 case EXT_START_CODE: | |
343 if (bytes_left >= 1) { | |
344 ext_type = (buf[0] >> 4); | |
345 switch(ext_type) { | |
346 case 0x1: /* sequence extension */ | |
347 if (bytes_left >= 6) { | |
348 horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7); | |
349 vert_size_ext = (buf[2] >> 5) & 3; | |
2539 | 350 bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1); |
1613 | 351 frame_rate_ext_n = (buf[5] >> 5) & 3; |
352 frame_rate_ext_d = (buf[5] & 0x1f); | |
353 pc->progressive_sequence = buf[1] & (1 << 3); | |
2565 | 354 avctx->has_b_frames= !(buf[5] >> 7); |
1613 | 355 |
2269 | 356 pc->width |=(horiz_size_ext << 12); |
357 pc->height |=( vert_size_ext << 12); | |
2539 | 358 avctx->bit_rate += (bit_rate_ext << 18) * 400; |
2270 | 359 avcodec_set_dimensions(avctx, pc->width, pc->height); |
2637 | 360 avctx->time_base.den = pc->frame_rate * (frame_rate_ext_n + 1); |
361 avctx->time_base.num = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1); | |
1681 | 362 avctx->codec_id = CODEC_ID_MPEG2VIDEO; |
1613 | 363 avctx->sub_id = 2; /* forces MPEG2 */ |
364 } | |
365 break; | |
366 case 0x8: /* picture coding extension */ | |
367 if (bytes_left >= 5) { | |
2120 | 368 picture_structure = buf[2]&3; |
1613 | 369 top_field_first = buf[3] & (1 << 7); |
370 repeat_first_field = buf[3] & (1 << 1); | |
371 progressive_frame = buf[4] & (1 << 7); | |
2967 | 372 |
1613 | 373 /* check if we must repeat the frame */ |
374 if (repeat_first_field) { | |
375 if (pc->progressive_sequence) { | |
376 if (top_field_first) | |
377 s->repeat_pict = 4; | |
378 else | |
379 s->repeat_pict = 2; | |
380 } else if (progressive_frame) { | |
381 s->repeat_pict = 1; | |
382 } | |
383 } | |
2967 | 384 |
385 /* the packet only represents half a frame | |
2119 | 386 XXX,FIXME maybe find a different solution */ |
387 if(picture_structure != 3) | |
388 s->repeat_pict = -1; | |
1613 | 389 } |
390 break; | |
391 } | |
392 } | |
393 break; | |
394 case -1: | |
395 goto the_end; | |
396 default: | |
397 /* we stop parsing when we encounter a slice. It ensures | |
398 that this function takes a negligible amount of time */ | |
2967 | 399 if (start_code >= SLICE_MIN_START_CODE && |
1613 | 400 start_code <= SLICE_MAX_START_CODE) |
401 goto the_end; | |
402 break; | |
403 } | |
404 } | |
405 the_end: ; | |
406 } | |
407 | |
408 static int mpegvideo_parse(AVCodecParserContext *s, | |
409 AVCodecContext *avctx, | |
2967 | 410 uint8_t **poutbuf, int *poutbuf_size, |
1613 | 411 const uint8_t *buf, int buf_size) |
412 { | |
1988 | 413 ParseContext1 *pc1 = s->priv_data; |
414 ParseContext *pc= &pc1->pc; | |
1613 | 415 int next; |
2967 | 416 |
2837 | 417 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ |
418 next= buf_size; | |
419 }else{ | |
420 next= ff_mpeg1_find_frame_end(pc, buf, buf_size); | |
2967 | 421 |
2837 | 422 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { |
423 *poutbuf = NULL; | |
424 *poutbuf_size = 0; | |
425 return buf_size; | |
426 } | |
2967 | 427 |
1613 | 428 } |
429 /* we have a full frame : we just parse the first few MPEG headers | |
430 to have the full timing information. The time take by this | |
431 function should be negligible for uncorrupted streams */ | |
432 mpegvideo_extract_headers(s, avctx, buf, buf_size); | |
433 #if 0 | |
2967 | 434 printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", |
2637 | 435 s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict); |
1613 | 436 #endif |
437 | |
438 *poutbuf = (uint8_t *)buf; | |
439 *poutbuf_size = buf_size; | |
440 return next; | |
441 } | |
442 | |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
443 static int mpegvideo_split(AVCodecContext *avctx, |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
444 const uint8_t *buf, int buf_size) |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
445 { |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
446 int i; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
447 uint32_t state= -1; |
2967 | 448 |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
449 for(i=0; i<buf_size; i++){ |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
450 state= (state<<8) | buf[i]; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
451 if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100) |
2777 | 452 return i-3; |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
453 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
454 return 0; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
455 } |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
456 #endif /* CONFIG_MPEGVIDEO_PARSER */ |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
457 |
1988 | 458 void ff_parse_close(AVCodecParserContext *s) |
1613 | 459 { |
1988 | 460 ParseContext *pc = s->priv_data; |
1613 | 461 |
462 av_free(pc->buffer); | |
1988 | 463 } |
464 | |
465 static void parse1_close(AVCodecParserContext *s) | |
466 { | |
467 ParseContext1 *pc1 = s->priv_data; | |
468 | |
469 av_free(pc1->pc.buffer); | |
470 av_free(pc1->enc); | |
1613 | 471 } |
472 | |
473 /*************************/ | |
474 | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
475 #ifdef CONFIG_MPEG4VIDEO_PARSER |
1613 | 476 /* used by parser */ |
477 /* XXX: make it use less memory */ | |
2967 | 478 static int av_mpeg4_decode_header(AVCodecParserContext *s1, |
1613 | 479 AVCodecContext *avctx, |
480 const uint8_t *buf, int buf_size) | |
481 { | |
482 ParseContext1 *pc = s1->priv_data; | |
483 MpegEncContext *s = pc->enc; | |
484 GetBitContext gb1, *gb = &gb1; | |
485 int ret; | |
486 | |
487 s->avctx = avctx; | |
1614 | 488 s->current_picture_ptr = &s->current_picture; |
489 | |
490 if (avctx->extradata_size && pc->first_picture){ | |
491 init_get_bits(gb, avctx->extradata, avctx->extradata_size*8); | |
492 ret = ff_mpeg4_decode_picture_header(s, gb); | |
493 } | |
494 | |
1613 | 495 init_get_bits(gb, buf, 8 * buf_size); |
496 ret = ff_mpeg4_decode_picture_header(s, gb); | |
497 if (s->width) { | |
2270 | 498 avcodec_set_dimensions(avctx, s->width, s->height); |
1613 | 499 } |
2837 | 500 s1->pict_type= s->pict_type; |
1614 | 501 pc->first_picture = 0; |
1613 | 502 return ret; |
503 } | |
504 | |
2024
f65d87bfdd5a
some of the warning fixes by (Michael Roitzsch <mroi at users dot sourceforge dot net>)
michael
parents:
1988
diff
changeset
|
505 static int mpeg4video_parse_init(AVCodecParserContext *s) |
1613 | 506 { |
507 ParseContext1 *pc = s->priv_data; | |
1614 | 508 |
1613 | 509 pc->enc = av_mallocz(sizeof(MpegEncContext)); |
510 if (!pc->enc) | |
511 return -1; | |
1614 | 512 pc->first_picture = 1; |
1613 | 513 return 0; |
514 } | |
515 | |
516 static int mpeg4video_parse(AVCodecParserContext *s, | |
517 AVCodecContext *avctx, | |
2967 | 518 uint8_t **poutbuf, int *poutbuf_size, |
1613 | 519 const uint8_t *buf, int buf_size) |
520 { | |
1988 | 521 ParseContext *pc = s->priv_data; |
1613 | 522 int next; |
2967 | 523 |
2837 | 524 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ |
525 next= buf_size; | |
526 }else{ | |
527 next= ff_mpeg4_find_frame_end(pc, buf, buf_size); | |
2967 | 528 |
2837 | 529 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { |
530 *poutbuf = NULL; | |
531 *poutbuf_size = 0; | |
532 return buf_size; | |
533 } | |
1613 | 534 } |
535 av_mpeg4_decode_header(s, avctx, buf, buf_size); | |
536 | |
537 *poutbuf = (uint8_t *)buf; | |
538 *poutbuf_size = buf_size; | |
539 return next; | |
540 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
541 #endif |
1613 | 542 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
543 #ifdef CONFIG_CAVSVIDEO_PARSER |
3395
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
544 static int cavsvideo_parse(AVCodecParserContext *s, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
545 AVCodecContext *avctx, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
546 uint8_t **poutbuf, int *poutbuf_size, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
547 const uint8_t *buf, int buf_size) |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
548 { |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
549 ParseContext *pc = s->priv_data; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
550 int next; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
551 |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
552 if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
553 next= buf_size; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
554 }else{ |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
555 next= ff_cavs_find_frame_end(pc, buf, buf_size); |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
556 |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
557 if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) { |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
558 *poutbuf = NULL; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
559 *poutbuf_size = 0; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
560 return buf_size; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
561 } |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
562 } |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
563 *poutbuf = (uint8_t *)buf; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
564 *poutbuf_size = buf_size; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
565 return next; |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
566 } |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
567 #endif /* CONFIG_CAVSVIDEO_PARSER */ |
3395
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
568 |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
569 static int mpeg4video_split(AVCodecContext *avctx, |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
570 const uint8_t *buf, int buf_size) |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
571 { |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
572 int i; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
573 uint32_t state= -1; |
2967 | 574 |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
575 for(i=0; i<buf_size; i++){ |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
576 state= (state<<8) | buf[i]; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
577 if(state == 0x1B3 || state == 0x1B6) |
2777 | 578 return i-3; |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
579 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
580 return 0; |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
581 } |
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
582 |
1613 | 583 /*************************/ |
584 | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
585 #ifdef CONFIG_MPEGAUDIO_PARSER |
1613 | 586 typedef struct MpegAudioParseContext { |
2979 | 587 uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */ |
1613 | 588 uint8_t *inbuf_ptr; |
589 int frame_size; | |
590 int free_format_frame_size; | |
591 int free_format_next_header; | |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
592 uint32_t header; |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
593 int header_count; |
1613 | 594 } MpegAudioParseContext; |
595 | |
596 #define MPA_HEADER_SIZE 4 | |
597 | |
598 /* header + layer + bitrate + freq + lsf/mpeg25 */ | |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2486
diff
changeset
|
599 #undef SAME_HEADER_MASK /* mpegaudio.h defines different version */ |
1613 | 600 #define SAME_HEADER_MASK \ |
2480 | 601 (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19)) |
1613 | 602 |
603 static int mpegaudio_parse_init(AVCodecParserContext *s1) | |
604 { | |
605 MpegAudioParseContext *s = s1->priv_data; | |
606 s->inbuf_ptr = s->inbuf; | |
607 return 0; | |
608 } | |
609 | |
610 static int mpegaudio_parse(AVCodecParserContext *s1, | |
611 AVCodecContext *avctx, | |
2967 | 612 uint8_t **poutbuf, int *poutbuf_size, |
1613 | 613 const uint8_t *buf, int buf_size) |
614 { | |
615 MpegAudioParseContext *s = s1->priv_data; | |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
616 int len, ret, sr; |
1613 | 617 uint32_t header; |
618 const uint8_t *buf_ptr; | |
619 | |
620 *poutbuf = NULL; | |
621 *poutbuf_size = 0; | |
622 buf_ptr = buf; | |
623 while (buf_size > 0) { | |
2979 | 624 len = s->inbuf_ptr - s->inbuf; |
625 if (s->frame_size == 0) { | |
1613 | 626 /* special case for next header for first frame in free |
627 format case (XXX: find a simpler method) */ | |
628 if (s->free_format_next_header != 0) { | |
629 s->inbuf[0] = s->free_format_next_header >> 24; | |
630 s->inbuf[1] = s->free_format_next_header >> 16; | |
631 s->inbuf[2] = s->free_format_next_header >> 8; | |
632 s->inbuf[3] = s->free_format_next_header; | |
633 s->inbuf_ptr = s->inbuf + 4; | |
634 s->free_format_next_header = 0; | |
635 goto got_header; | |
636 } | |
2979 | 637 /* no header seen : find one. We need at least MPA_HEADER_SIZE |
1613 | 638 bytes to parse it */ |
3639
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
639 len = FFMIN(MPA_HEADER_SIZE - len, buf_size); |
2979 | 640 if (len > 0) { |
641 memcpy(s->inbuf_ptr, buf_ptr, len); | |
642 buf_ptr += len; | |
643 buf_size -= len; | |
644 s->inbuf_ptr += len; | |
645 } | |
646 if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) { | |
1613 | 647 got_header: |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
648 sr= avctx->sample_rate; |
2979 | 649 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | |
650 (s->inbuf[2] << 8) | s->inbuf[3]; | |
1613 | 651 |
652 ret = mpa_decode_header(avctx, header); | |
653 if (ret < 0) { | |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
654 s->header_count= -2; |
2979 | 655 /* no sync found : move by one byte (inefficient, but simple!) */ |
656 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); | |
657 s->inbuf_ptr--; | |
1613 | 658 dprintf("skip %x\n", header); |
659 /* reset free format frame size to give a chance | |
660 to get a new bitrate */ | |
661 s->free_format_frame_size = 0; | |
2979 | 662 } else { |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
663 if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header) |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
664 s->header_count= -3; |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
665 s->header= header; |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
666 s->header_count++; |
1613 | 667 s->frame_size = ret; |
2967 | 668 |
1613 | 669 #if 0 |
670 /* free format: prepare to compute frame size */ | |
2979 | 671 if (decode_header(s, header) == 1) { |
672 s->frame_size = -1; | |
1613 | 673 } |
674 #endif | |
2979 | 675 } |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
676 if(s->header_count <= 0) |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
677 avctx->sample_rate= sr; //FIXME ugly |
2979 | 678 } |
2967 | 679 } else |
1613 | 680 #if 0 |
681 if (s->frame_size == -1) { | |
682 /* free format : find next sync to compute frame size */ | |
2979 | 683 len = MPA_MAX_CODED_FRAME_SIZE - len; |
684 if (len > buf_size) | |
685 len = buf_size; | |
1613 | 686 if (len == 0) { |
2979 | 687 /* frame too long: resync */ |
1613 | 688 s->frame_size = 0; |
2979 | 689 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); |
690 s->inbuf_ptr--; | |
1613 | 691 } else { |
692 uint8_t *p, *pend; | |
693 uint32_t header1; | |
694 int padding; | |
695 | |
696 memcpy(s->inbuf_ptr, buf_ptr, len); | |
697 /* check for header */ | |
698 p = s->inbuf_ptr - 3; | |
699 pend = s->inbuf_ptr + len - 4; | |
700 while (p <= pend) { | |
701 header = (p[0] << 24) | (p[1] << 16) | | |
702 (p[2] << 8) | p[3]; | |
703 header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | | |
704 (s->inbuf[2] << 8) | s->inbuf[3]; | |
705 /* check with high probability that we have a | |
706 valid header */ | |
707 if ((header & SAME_HEADER_MASK) == | |
708 (header1 & SAME_HEADER_MASK)) { | |
709 /* header found: update pointers */ | |
710 len = (p + 4) - s->inbuf_ptr; | |
711 buf_ptr += len; | |
712 buf_size -= len; | |
713 s->inbuf_ptr = p; | |
714 /* compute frame size */ | |
715 s->free_format_next_header = header; | |
716 s->free_format_frame_size = s->inbuf_ptr - s->inbuf; | |
717 padding = (header1 >> 9) & 1; | |
718 if (s->layer == 1) | |
719 s->free_format_frame_size -= padding * 4; | |
720 else | |
721 s->free_format_frame_size -= padding; | |
2967 | 722 dprintf("free frame size=%d padding=%d\n", |
1613 | 723 s->free_format_frame_size, padding); |
724 decode_header(s, header1); | |
725 goto next_data; | |
726 } | |
727 p++; | |
728 } | |
729 /* not found: simply increase pointers */ | |
730 buf_ptr += len; | |
731 s->inbuf_ptr += len; | |
732 buf_size -= len; | |
733 } | |
2979 | 734 } else |
1613 | 735 #endif |
736 if (len < s->frame_size) { | |
737 if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) | |
738 s->frame_size = MPA_MAX_CODED_FRAME_SIZE; | |
3639
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
739 len = FFMIN(s->frame_size - len, buf_size); |
2979 | 740 memcpy(s->inbuf_ptr, buf_ptr, len); |
741 buf_ptr += len; | |
742 s->inbuf_ptr += len; | |
743 buf_size -= len; | |
744 } | |
3639
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
745 |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
746 if(s->frame_size > 0 && buf_ptr - buf == s->inbuf_ptr - s->inbuf |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
747 && buf_size + buf_ptr - buf >= s->frame_size){ |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
748 if(s->header_count > 0){ |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
749 *poutbuf = buf; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
750 *poutbuf_size = s->frame_size; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
751 } |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
752 buf_ptr = buf + s->frame_size; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
753 s->inbuf_ptr = s->inbuf; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
754 s->frame_size = 0; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
755 break; |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
756 } |
949bc256f1e3
dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
michael
parents:
3456
diff
changeset
|
757 |
1613 | 758 // next_data: |
2967 | 759 if (s->frame_size > 0 && |
1613 | 760 (s->inbuf_ptr - s->inbuf) >= s->frame_size) { |
2470
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
761 if(s->header_count > 0){ |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
762 *poutbuf = s->inbuf; |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
763 *poutbuf_size = s->inbuf_ptr - s->inbuf; |
06aafb585f69
require a few valid and equal mp3 headers for resync
michael
parents:
2389
diff
changeset
|
764 } |
2979 | 765 s->inbuf_ptr = s->inbuf; |
766 s->frame_size = 0; | |
767 break; | |
768 } | |
1613 | 769 } |
770 return buf_ptr - buf; | |
771 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
772 #endif /* CONFIG_MPEGAUDIO_PARSER */ |
1613 | 773 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
774 #if defined(CONFIG_AC3_PARSER) || defined(CONFIG_AAC_PARSER) |
3098 | 775 /* also used for ADTS AAC */ |
1613 | 776 typedef struct AC3ParseContext { |
777 uint8_t *inbuf_ptr; | |
778 int frame_size; | |
3098 | 779 int header_size; |
780 int (*sync)(const uint8_t *buf, int *channels, int *sample_rate, | |
781 int *bit_rate, int *samples); | |
3344
f9d739057d6c
The AAC frame header uses 13 bits for the frame size, so the buffer should
mru
parents:
3104
diff
changeset
|
782 uint8_t inbuf[8192]; /* input buffer */ |
1613 | 783 } AC3ParseContext; |
784 | |
785 #define AC3_HEADER_SIZE 7 | |
3104 | 786 #define AAC_HEADER_SIZE 7 |
3059 | 787 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
788 #ifdef CONFIG_AC3_PARSER |
3059 | 789 static const int ac3_sample_rates[4] = { |
790 48000, 44100, 32000, 0 | |
791 }; | |
792 | |
793 static const int ac3_frame_sizes[64][3] = { | |
3063
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
794 { 64, 69, 96 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
795 { 64, 70, 96 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
796 { 80, 87, 120 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
797 { 80, 88, 120 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
798 { 96, 104, 144 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
799 { 96, 105, 144 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
800 { 112, 121, 168 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
801 { 112, 122, 168 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
802 { 128, 139, 192 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
803 { 128, 140, 192 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
804 { 160, 174, 240 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
805 { 160, 175, 240 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
806 { 192, 208, 288 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
807 { 192, 209, 288 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
808 { 224, 243, 336 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
809 { 224, 244, 336 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
810 { 256, 278, 384 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
811 { 256, 279, 384 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
812 { 320, 348, 480 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
813 { 320, 349, 480 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
814 { 384, 417, 576 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
815 { 384, 418, 576 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
816 { 448, 487, 672 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
817 { 448, 488, 672 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
818 { 512, 557, 768 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
819 { 512, 558, 768 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
820 { 640, 696, 960 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
821 { 640, 697, 960 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
822 { 768, 835, 1152 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
823 { 768, 836, 1152 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
824 { 896, 975, 1344 }, |
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
825 { 896, 976, 1344 }, |
3059 | 826 { 1024, 1114, 1536 }, |
827 { 1024, 1115, 1536 }, | |
828 { 1152, 1253, 1728 }, | |
829 { 1152, 1254, 1728 }, | |
830 { 1280, 1393, 1920 }, | |
831 { 1280, 1394, 1920 }, | |
832 }; | |
833 | |
834 static const int ac3_bitrates[64] = { | |
835 32, 32, 40, 40, 48, 48, 56, 56, 64, 64, 80, 80, 96, 96, 112, 112, | |
836 128, 128, 160, 160, 192, 192, 224, 224, 256, 256, 320, 320, 384, | |
837 384, 448, 448, 512, 512, 576, 576, 640, 640, | |
838 }; | |
839 | |
840 static const int ac3_channels[8] = { | |
841 2, 1, 2, 3, 3, 4, 4, 5 | |
842 }; | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
843 #endif /* CONFIG_AC3_PARSER */ |
3059 | 844 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
845 #ifdef CONFIG_AAC_PARSER |
3456 | 846 static const int aac_sample_rates[16] = { |
3098 | 847 96000, 88200, 64000, 48000, 44100, 32000, |
848 24000, 22050, 16000, 12000, 11025, 8000, 7350 | |
849 }; | |
850 | |
3456 | 851 static const int aac_channels[8] = { |
3098 | 852 0, 1, 2, 3, 4, 5, 6, 8 |
853 }; | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
854 #endif |
3098 | 855 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
856 #ifdef CONFIG_AC3_PARSER |
3059 | 857 static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, |
3098 | 858 int *bit_rate, int *samples) |
3059 | 859 { |
860 unsigned int fscod, frmsizecod, acmod, bsid, lfeon; | |
861 GetBitContext bits; | |
862 | |
863 init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8); | |
864 | |
865 if(get_bits(&bits, 16) != 0x0b77) | |
3063
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
866 return 0; |
3059 | 867 |
3104 | 868 skip_bits(&bits, 16); /* crc */ |
3059 | 869 fscod = get_bits(&bits, 2); |
870 frmsizecod = get_bits(&bits, 6); | |
871 | |
872 if(!ac3_sample_rates[fscod]) | |
3063
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
873 return 0; |
3059 | 874 |
875 bsid = get_bits(&bits, 5); | |
876 if(bsid > 8) | |
3063
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
877 return 0; |
3104 | 878 skip_bits(&bits, 3); /* bsmod */ |
3059 | 879 acmod = get_bits(&bits, 3); |
880 if(acmod & 1 && acmod != 1) | |
3104 | 881 skip_bits(&bits, 2); /* cmixlev */ |
3059 | 882 if(acmod & 4) |
3104 | 883 skip_bits(&bits, 2); /* surmixlev */ |
3059 | 884 if(acmod & 2) |
3104 | 885 skip_bits(&bits, 2); /* dsurmod */ |
886 lfeon = get_bits1(&bits); | |
3059 | 887 |
888 *sample_rate = ac3_sample_rates[fscod]; | |
889 *bit_rate = ac3_bitrates[frmsizecod] * 1000; | |
890 *channels = ac3_channels[acmod] + lfeon; | |
3098 | 891 *samples = 6 * 256; |
3059 | 892 |
893 return ac3_frame_sizes[frmsizecod][fscod] * 2; | |
894 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
895 #endif /* CONFIG_AC3_PARSER */ |
1613 | 896 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
897 #ifdef CONFIG_AAC_PARSER |
3098 | 898 static int aac_sync(const uint8_t *buf, int *channels, int *sample_rate, |
899 int *bit_rate, int *samples) | |
900 { | |
901 GetBitContext bits; | |
902 int size, rdb, ch, sr; | |
903 | |
904 init_get_bits(&bits, buf, AAC_HEADER_SIZE * 8); | |
905 | |
906 if(get_bits(&bits, 12) != 0xfff) | |
907 return 0; | |
908 | |
3104 | 909 skip_bits1(&bits); /* id */ |
910 skip_bits(&bits, 2); /* layer */ | |
911 skip_bits1(&bits); /* protection_absent */ | |
912 skip_bits(&bits, 2); /* profile_objecttype */ | |
913 sr = get_bits(&bits, 4); /* sample_frequency_index */ | |
3098 | 914 if(!aac_sample_rates[sr]) |
915 return 0; | |
3104 | 916 skip_bits1(&bits); /* private_bit */ |
917 ch = get_bits(&bits, 3); /* channel_configuration */ | |
3098 | 918 if(!aac_channels[ch]) |
919 return 0; | |
3104 | 920 skip_bits1(&bits); /* original/copy */ |
921 skip_bits1(&bits); /* home */ | |
3098 | 922 |
923 /* adts_variable_header */ | |
3104 | 924 skip_bits1(&bits); /* copyright_identification_bit */ |
925 skip_bits1(&bits); /* copyright_identification_start */ | |
926 size = get_bits(&bits, 13); /* aac_frame_length */ | |
927 skip_bits(&bits, 11); /* adts_buffer_fullness */ | |
928 rdb = get_bits(&bits, 2); /* number_of_raw_data_blocks_in_frame */ | |
3098 | 929 |
930 *channels = aac_channels[ch]; | |
931 *sample_rate = aac_sample_rates[sr]; | |
932 *samples = (rdb + 1) * 1024; | |
933 *bit_rate = size * 8 * *sample_rate / *samples; | |
934 | |
935 return size; | |
936 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
937 #endif /* CONFIG_AAC_PARSER */ |
3098 | 938 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
939 #ifdef CONFIG_AC3_PARSER |
1613 | 940 static int ac3_parse_init(AVCodecParserContext *s1) |
941 { | |
942 AC3ParseContext *s = s1->priv_data; | |
943 s->inbuf_ptr = s->inbuf; | |
3098 | 944 s->header_size = AC3_HEADER_SIZE; |
945 s->sync = ac3_sync; | |
1613 | 946 return 0; |
947 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
948 #endif |
1613 | 949 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
950 #ifdef CONFIG_AAC_PARSER |
3098 | 951 static int aac_parse_init(AVCodecParserContext *s1) |
952 { | |
953 AC3ParseContext *s = s1->priv_data; | |
954 s->inbuf_ptr = s->inbuf; | |
955 s->header_size = AAC_HEADER_SIZE; | |
956 s->sync = aac_sync; | |
957 return 0; | |
958 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
959 #endif |
3098 | 960 |
961 /* also used for ADTS AAC */ | |
1613 | 962 static int ac3_parse(AVCodecParserContext *s1, |
963 AVCodecContext *avctx, | |
2967 | 964 uint8_t **poutbuf, int *poutbuf_size, |
1613 | 965 const uint8_t *buf, int buf_size) |
966 { | |
967 AC3ParseContext *s = s1->priv_data; | |
968 const uint8_t *buf_ptr; | |
3098 | 969 int len, sample_rate, bit_rate, channels, samples; |
1613 | 970 |
971 *poutbuf = NULL; | |
972 *poutbuf_size = 0; | |
973 | |
974 buf_ptr = buf; | |
975 while (buf_size > 0) { | |
976 len = s->inbuf_ptr - s->inbuf; | |
977 if (s->frame_size == 0) { | |
3098 | 978 /* no header seen : find one. We need at least s->header_size |
979 bytes to parse it */ | |
980 len = FFMIN(s->header_size - len, buf_size); | |
3082 | 981 |
1613 | 982 memcpy(s->inbuf_ptr, buf_ptr, len); |
983 buf_ptr += len; | |
984 s->inbuf_ptr += len; | |
985 buf_size -= len; | |
3098 | 986 if ((s->inbuf_ptr - s->inbuf) == s->header_size) { |
987 len = s->sync(s->inbuf, &channels, &sample_rate, &bit_rate, | |
988 &samples); | |
1613 | 989 if (len == 0) { |
990 /* no sync found : move by one byte (inefficient, but simple!) */ | |
3098 | 991 memmove(s->inbuf, s->inbuf + 1, s->header_size - 1); |
1613 | 992 s->inbuf_ptr--; |
993 } else { | |
2979 | 994 s->frame_size = len; |
1613 | 995 /* update codec info */ |
996 avctx->sample_rate = sample_rate; | |
1987 | 997 /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */ |
3098 | 998 if(avctx->codec_id == CODEC_ID_AC3){ |
999 if(avctx->channels!=1 && avctx->channels!=2){ | |
1000 avctx->channels = channels; | |
1001 } | |
1002 } else { | |
3063
f02d0b59279c
Remove all stray tabs and trailing whitespace, this time for good.
diego
parents:
3059
diff
changeset
|
1003 avctx->channels = channels; |
1987 | 1004 } |
2979 | 1005 avctx->bit_rate = bit_rate; |
3098 | 1006 avctx->frame_size = samples; |
1613 | 1007 } |
1008 } | |
3082 | 1009 } else { |
1010 len = FFMIN(s->frame_size - len, buf_size); | |
1613 | 1011 |
1012 memcpy(s->inbuf_ptr, buf_ptr, len); | |
1013 buf_ptr += len; | |
1014 s->inbuf_ptr += len; | |
1015 buf_size -= len; | |
3082 | 1016 |
1017 if(s->inbuf_ptr - s->inbuf == s->frame_size){ | |
1018 *poutbuf = s->inbuf; | |
1019 *poutbuf_size = s->frame_size; | |
1020 s->inbuf_ptr = s->inbuf; | |
1021 s->frame_size = 0; | |
1022 break; | |
1023 } | |
1613 | 1024 } |
1025 } | |
1026 return buf_ptr - buf; | |
1027 } | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1028 #endif /* CONFIG_AC3_PARSER || CONFIG_AAC_PARSER */ |
1613 | 1029 |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1030 #ifdef CONFIG_MPEGVIDEO_PARSER |
1613 | 1031 AVCodecParser mpegvideo_parser = { |
1032 { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO }, | |
1033 sizeof(ParseContext1), | |
1034 NULL, | |
1035 mpegvideo_parse, | |
1988 | 1036 parse1_close, |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
1037 mpegvideo_split, |
1613 | 1038 }; |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1039 #endif |
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1040 #ifdef CONFIG_MPEG4VIDEO_PARSER |
1613 | 1041 AVCodecParser mpeg4video_parser = { |
1042 { CODEC_ID_MPEG4 }, | |
1043 sizeof(ParseContext1), | |
1044 mpeg4video_parse_init, | |
1045 mpeg4video_parse, | |
1988 | 1046 parse1_close, |
2769
1394b45a7bf4
support changing in bitstream global headers into extradata style and back
michael
parents:
2637
diff
changeset
|
1047 mpeg4video_split, |
1613 | 1048 }; |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1049 #endif |
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1050 #ifdef CONFIG_CAVSVIDEO_PARSER |
3395
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1051 AVCodecParser cavsvideo_parser = { |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1052 { CODEC_ID_CAVS }, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1053 sizeof(ParseContext1), |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1054 NULL, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1055 cavsvideo_parse, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1056 parse1_close, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1057 mpeg4video_split, |
adccbf4a1040
CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
michael
parents:
3344
diff
changeset
|
1058 }; |
3432 | 1059 #endif |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1060 #ifdef CONFIG_MPEGAUDIO_PARSER |
1613 | 1061 AVCodecParser mpegaudio_parser = { |
1062 { CODEC_ID_MP2, CODEC_ID_MP3 }, | |
1063 sizeof(MpegAudioParseContext), | |
1064 mpegaudio_parse_init, | |
1065 mpegaudio_parse, | |
1066 NULL, | |
1067 }; | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1068 #endif |
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1069 #ifdef CONFIG_AC3_PARSER |
1613 | 1070 AVCodecParser ac3_parser = { |
1071 { CODEC_ID_AC3 }, | |
1072 sizeof(AC3ParseContext), | |
1073 ac3_parse_init, | |
1074 ac3_parse, | |
1075 NULL, | |
1076 }; | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1077 #endif |
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1078 #ifdef CONFIG_AAC_PARSER |
3098 | 1079 AVCodecParser aac_parser = { |
1080 { CODEC_ID_AAC }, | |
1081 sizeof(AC3ParseContext), | |
1082 aac_parse_init, | |
1083 ac3_parse, | |
1084 NULL, | |
1085 }; | |
3455
cc4b4ea83e29
--enable/disable parsers. Warning: some combinations are broken.
mru
parents:
3432
diff
changeset
|
1086 #endif |