annotate parser.c @ 1613:0279c6c61f11 libavcodec

new audio/video parser API
author bellard
date Mon, 10 Nov 2003 15:29:20 +0000
parents
children 6c82ef97d3e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1613
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
1 /*
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
2 * Audio and Video frame extraction
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
4 * Copyright (c) 2003 Michael Niedermayer.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
5 *
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
10 *
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
14 * Lesser General Public License for more details.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
15 *
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
19 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
20 #include "avcodec.h"
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
21 #include "mpegvideo.h"
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
22 #include "mpegaudio.h"
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
23
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
24 AVCodecParser *av_first_parser = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
25
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
26 void av_register_codec_parser(AVCodecParser *parser)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
27 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
28 parser->next = av_first_parser;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
29 av_first_parser = parser;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
30 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
31
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
32 AVCodecParserContext *av_parser_init(int codec_id)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
33 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
34 AVCodecParserContext *s;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
35 AVCodecParser *parser;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
36 int ret;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
37
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
38 for(parser = av_first_parser; parser != NULL; parser = parser->next) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
39 if (parser->codec_ids[0] == codec_id ||
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
40 parser->codec_ids[1] == codec_id ||
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
41 parser->codec_ids[2] == codec_id)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
42 goto found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
43 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
44 return NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
45 found:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
46 s = av_mallocz(sizeof(AVCodecParserContext));
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
47 if (!s)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
48 return NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
49 s->parser = parser;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
50 s->priv_data = av_mallocz(parser->priv_data_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
51 if (!s->priv_data) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
52 av_free(s);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
53 return NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
54 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
55 if (parser->parser_init) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
56 ret = parser->parser_init(s);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
57 if (ret != 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
58 av_free(s->priv_data);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
59 av_free(s);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
60 return NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
61 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
62 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
63 return s;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
64 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
65
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
66 int av_parser_parse(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
67 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
68 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
69 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
70 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
71 int index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
72 /* WARNING: the returned index can be negative */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
73 index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
74 /* update the file pointer */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
75 if (*poutbuf_size) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
76 s->frame_offset = s->last_frame_offset;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
77 s->last_frame_offset = s->cur_offset + index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
78 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
79 if (index < 0)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
80 index = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
81 s->cur_offset += index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
82 return index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
83 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
84
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
85 void av_parser_close(AVCodecParserContext *s)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
86 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
87 if (s->parser->parser_close)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
88 s->parser->parser_close(s);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
89 av_free(s->priv_data);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
90 av_free(s);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
91 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
92
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
93 /*****************************************************/
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
94
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
95 //#define END_NOT_FOUND (-100)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
96
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
97 #define PICTURE_START_CODE 0x00000100
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
98 #define SEQ_START_CODE 0x000001b3
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
99 #define EXT_START_CODE 0x000001b5
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
100 #define SLICE_MIN_START_CODE 0x00000101
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
101 #define SLICE_MAX_START_CODE 0x000001af
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
102
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
103 typedef struct ParseContext1{
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
104 uint8_t *buffer;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
105 int index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
106 int last_index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
107 int buffer_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
108 uint32_t state; ///< contains the last few bytes in MSB order
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
109 int frame_start_found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
110 int overread; ///< the number of bytes which where irreversibly read from the next frame
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
111 int overread_index; ///< the index into ParseContext1.buffer of the overreaded bytes
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
112
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
113 /* MPEG2 specific */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
114 int frame_rate;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
115 int progressive_sequence;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
116 int width, height;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
117 /* XXX: suppress that, needed by MPEG4 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
118 MpegEncContext *enc;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
119 } ParseContext1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
120
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
121 /**
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
122 * combines the (truncated) bitstream to a complete frame
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
123 * @returns -1 if no complete frame could be created
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
124 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
125 static int ff_combine_frame1(ParseContext1 *pc, int next, uint8_t **buf, int *buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
126 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
127 #if 0
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
128 if(pc->overread){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
129 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
130 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
131 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
132 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
133
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
134 /* copy overreaded bytes from last frame into buffer */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
135 for(; pc->overread>0; pc->overread--){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
136 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
137 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
138
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
139 pc->last_index= pc->index;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
140
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
141 /* copy into buffer end return */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
142 if(next == END_NOT_FOUND){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
143 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
144
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
145 memcpy(&pc->buffer[pc->index], *buf, *buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
146 pc->index += *buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
147 return -1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
148 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
149
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
150 *buf_size=
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
151 pc->overread_index= pc->index + next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
152
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
153 /* append to buffer */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
154 if(pc->index){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
155 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
156
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
157 memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
158 pc->index = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
159 *buf= pc->buffer;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
160 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
161
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
162 /* store overread bytes */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
163 for(;next < 0; next++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
164 pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
165 pc->overread++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
166 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
167
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
168 #if 0
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
169 if(pc->overread){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
170 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
171 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
172 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
173 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
174
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
175 return 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
176 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
177
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
178 /**
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
179 * finds the end of the current frame in the bitstream.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
180 * @return the position of the first byte of the next frame, or -1
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
181 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
182 static int mpeg1_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
183 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
184 int i;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
185 uint32_t state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
186
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
187 state= pc->state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
188
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
189 i=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
190 if(!pc->frame_start_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
191 for(i=0; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
192 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
193 if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
194 i++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
195 pc->frame_start_found=1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
196 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
197 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
198 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
199 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
200
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
201 if(pc->frame_start_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
202 for(; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
203 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
204 if((state&0xFFFFFF00) == 0x100){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
205 if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
206 pc->frame_start_found=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
207 pc->state=-1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
208 return i-3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
209 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
210 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
211 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
212 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
213 pc->state= state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
214 return END_NOT_FOUND;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
215 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
216
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
217 static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
218 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
219 const uint8_t *buf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
220 unsigned int state=0xFFFFFFFF, v;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
221 int val;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
222
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
223 buf_ptr = *pbuf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
224 while (buf_ptr < buf_end) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
225 v = *buf_ptr++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
226 if (state == 0x000001) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
227 state = ((state << 8) | v) & 0xffffff;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
228 val = state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
229 goto found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
230 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
231 state = ((state << 8) | v) & 0xffffff;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
232 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
233 val = -1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
234 found:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
235 *pbuf_ptr = buf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
236 return val;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
237 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
238
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
239 /* XXX: merge with libavcodec ? */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
240 #define MPEG1_FRAME_RATE_BASE 1001
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
241
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
242 static const int frame_rate_tab[16] = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
243 0,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
244 24000,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
245 24024,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
246 25025,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
247 30000,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
248 30030,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
249 50050,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
250 60000,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
251 60060,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
252 // Xing's 15fps: (9)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
253 15015,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
254 // libmpeg3's "Unofficial economy rates": (10-13)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
255 5005,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
256 10010,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
257 12012,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
258 15015,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
259 // random, just to avoid segfault !never encode these
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
260 25025,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
261 25025,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
262 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
263
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
264 static void mpegvideo_extract_headers(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
265 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
266 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
267 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
268 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
269 const uint8_t *buf_end;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
270 int32_t start_code;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
271 int frame_rate_index, ext_type, bytes_left;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
272 int frame_rate_ext_n, frame_rate_ext_d;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
273 int top_field_first, repeat_first_field, progressive_frame;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
274 int horiz_size_ext, vert_size_ext;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
275
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
276 s->repeat_pict = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
277 buf_end = buf + buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
278 while (buf < buf_end) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
279 start_code = find_start_code(&buf, buf_end);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
280 bytes_left = buf_end - buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
281 switch(start_code) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
282 case PICTURE_START_CODE:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
283 if (bytes_left >= 2) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
284 s->pict_type = (buf[1] >> 3) & 7;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
285 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
286 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
287 case SEQ_START_CODE:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
288 if (bytes_left >= 4) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
289 pc->width = avctx->width = (buf[0] << 4) | (buf[1] >> 4);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
290 pc->height = avctx->height = ((buf[1] & 0x0f) << 8) | buf[2];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
291 frame_rate_index = buf[3] & 0xf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
292 pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
293 avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
294 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
295 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
296 case EXT_START_CODE:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
297 if (bytes_left >= 1) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
298 ext_type = (buf[0] >> 4);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
299 switch(ext_type) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
300 case 0x1: /* sequence extension */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
301 if (bytes_left >= 6) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
302 horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
303 vert_size_ext = (buf[2] >> 5) & 3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
304 frame_rate_ext_n = (buf[5] >> 5) & 3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
305 frame_rate_ext_d = (buf[5] & 0x1f);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
306 pc->progressive_sequence = buf[1] & (1 << 3);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
307
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
308 avctx->width = pc->width | (horiz_size_ext << 12);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
309 avctx->height = pc->height | (vert_size_ext << 12);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
310 avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
311 avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
312 avctx->sub_id = 2; /* forces MPEG2 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
313 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
314 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
315 case 0x8: /* picture coding extension */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
316 if (bytes_left >= 5) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
317 top_field_first = buf[3] & (1 << 7);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
318 repeat_first_field = buf[3] & (1 << 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
319 progressive_frame = buf[4] & (1 << 7);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
320
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
321 /* check if we must repeat the frame */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
322 if (repeat_first_field) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
323 if (pc->progressive_sequence) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
324 if (top_field_first)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
325 s->repeat_pict = 4;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
326 else
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
327 s->repeat_pict = 2;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
328 } else if (progressive_frame) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
329 s->repeat_pict = 1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
330 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
331 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
332 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
333 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
334 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
335 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
336 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
337 case -1:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
338 goto the_end;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
339 default:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
340 /* we stop parsing when we encounter a slice. It ensures
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
341 that this function takes a negligible amount of time */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
342 if (start_code >= SLICE_MIN_START_CODE &&
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
343 start_code <= SLICE_MAX_START_CODE)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
344 goto the_end;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
345 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
346 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
347 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
348 the_end: ;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
349 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
350
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
351 static int mpegvideo_parse(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
352 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
353 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
354 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
355 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
356 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
357 int next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
358
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
359 next= mpeg1_find_frame_end(pc, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
360
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
361 if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
362 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
363 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
364 return buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
365 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
366 /* we have a full frame : we just parse the first few MPEG headers
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
367 to have the full timing information. The time take by this
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
368 function should be negligible for uncorrupted streams */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
369 mpegvideo_extract_headers(s, avctx, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
370 #if 0
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
371 printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
372 s->pict_type, (double)avctx->frame_rate / avctx->frame_rate_base, s->repeat_pict);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
373 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
374
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
375 *poutbuf = (uint8_t *)buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
376 *poutbuf_size = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
377 return next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
378 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
379
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
380 static void mpegvideo_parse_close(AVCodecParserContext *s)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
381 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
382 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
383
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
384 av_free(pc->buffer);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
385 av_free(pc->enc);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
386 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
387
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
388 /*************************/
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
389
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
390 /**
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
391 * finds the end of the current frame in the bitstream.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
392 * @return the position of the first byte of the next frame, or -1
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
393 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
394 static int mpeg4_find_frame_end(ParseContext1 *pc,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
395 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
396 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
397 int vop_found, i;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
398 uint32_t state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
399
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
400 vop_found= pc->frame_start_found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
401 state= pc->state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
402
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
403 i=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
404 if(!vop_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
405 for(i=0; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
406 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
407 if(state == 0x1B6){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
408 i++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
409 vop_found=1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
410 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
411 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
412 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
413 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
414
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
415 if(vop_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
416 for(; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
417 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
418 if((state&0xFFFFFF00) == 0x100){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
419 pc->frame_start_found=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
420 pc->state=-1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
421 return i-3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
422 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
423 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
424 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
425 pc->frame_start_found= vop_found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
426 pc->state= state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
427 return END_NOT_FOUND;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
428 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
429
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
430 /* used by parser */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
431 /* XXX: make it use less memory */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
432 static int av_mpeg4_decode_header(AVCodecParserContext *s1,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
433 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
434 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
435 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
436 ParseContext1 *pc = s1->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
437 MpegEncContext *s = pc->enc;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
438 GetBitContext gb1, *gb = &gb1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
439 int ret;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
440
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
441 s->avctx = avctx;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
442 init_get_bits(gb, buf, 8 * buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
443 ret = ff_mpeg4_decode_picture_header(s, gb);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
444 if (s->width) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
445 avctx->width = s->width;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
446 avctx->height = s->height;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
447 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
448 return ret;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
449 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
450
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
451 int mpeg4video_parse_init(AVCodecParserContext *s)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
452 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
453 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
454 pc->enc = av_mallocz(sizeof(MpegEncContext));
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
455 if (!pc->enc)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
456 return -1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
457 return 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
458 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
459
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
460 static int mpeg4video_parse(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
461 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
462 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
463 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
464 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
465 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
466 int next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
467
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
468 next= mpeg4_find_frame_end(pc, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
469
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
470 if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
471 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
472 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
473 return buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
474 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
475 av_mpeg4_decode_header(s, avctx, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
476
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
477 *poutbuf = (uint8_t *)buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
478 *poutbuf_size = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
479 return next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
480 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
481
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
482 /*************************/
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
483
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
484 static int h263_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
485 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
486 int vop_found, i;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
487 uint32_t state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
488
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
489 vop_found= pc->frame_start_found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
490 state= pc->state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
491
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
492 i=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
493 if(!vop_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
494 for(i=0; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
495 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
496 if(state>>(32-22) == 0x20){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
497 i++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
498 vop_found=1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
499 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
500 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
501 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
502 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
503
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
504 if(vop_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
505 for(; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
506 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
507 if(state>>(32-22) == 0x20){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
508 pc->frame_start_found=0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
509 pc->state=-1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
510 return i-3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
511 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
512 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
513 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
514 pc->frame_start_found= vop_found;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
515 pc->state= state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
516
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
517 return END_NOT_FOUND;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
518 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
519
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
520 static int h263_parse(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
521 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
522 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
523 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
524 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
525 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
526 int next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
527
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
528 next= h263_find_frame_end(pc, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
529
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
530 if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
531 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
532 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
533 return buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
534 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
535
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
536 *poutbuf = (uint8_t *)buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
537 *poutbuf_size = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
538 return next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
539 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
540
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
541 /*************************/
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
542
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
543 /**
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
544 * finds the end of the current frame in the bitstream.
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
545 * @return the position of the first byte of the next frame, or -1
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
546 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
547 static int h264_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
548 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
549 int i;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
550 uint32_t state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
551 //printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
552 // mb_addr= pc->mb_addr - 1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
553 state= pc->state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
554 //FIXME this will fail with slices
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
555 for(i=0; i<buf_size; i++){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
556 state= (state<<8) | buf[i];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
557 if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
558 if(pc->frame_start_found){
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
559 pc->state=-1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
560 pc->frame_start_found= 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
561 return i-3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
562 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
563 pc->frame_start_found= 1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
564 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
565 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
566
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
567 pc->state= state;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
568 return END_NOT_FOUND;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
569 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
570
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
571 static int h264_parse(AVCodecParserContext *s,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
572 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
573 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
574 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
575 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
576 ParseContext1 *pc = s->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
577 int next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
578
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
579 next= h264_find_frame_end(pc, buf, buf_size);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
580
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
581 if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
582 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
583 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
584 return buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
585 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
586
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
587 *poutbuf = (uint8_t *)buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
588 *poutbuf_size = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
589 return next;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
590 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
591
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
592 /*************************/
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
593
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
594 typedef struct MpegAudioParseContext {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
595 uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
596 uint8_t *inbuf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
597 int frame_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
598 int free_format_frame_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
599 int free_format_next_header;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
600 } MpegAudioParseContext;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
601
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
602 #define MPA_HEADER_SIZE 4
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
603
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
604 /* header + layer + bitrate + freq + lsf/mpeg25 */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
605 #define SAME_HEADER_MASK \
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
606 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
607
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
608 static int mpegaudio_parse_init(AVCodecParserContext *s1)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
609 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
610 MpegAudioParseContext *s = s1->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
611 s->inbuf_ptr = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
612 return 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
613 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
614
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
615 static int mpegaudio_parse(AVCodecParserContext *s1,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
616 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
617 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
618 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
619 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
620 MpegAudioParseContext *s = s1->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
621 int len, ret;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
622 uint32_t header;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
623 const uint8_t *buf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
624
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
625 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
626 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
627 buf_ptr = buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
628 while (buf_size > 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
629 len = s->inbuf_ptr - s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
630 if (s->frame_size == 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
631 /* special case for next header for first frame in free
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
632 format case (XXX: find a simpler method) */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
633 if (s->free_format_next_header != 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
634 s->inbuf[0] = s->free_format_next_header >> 24;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
635 s->inbuf[1] = s->free_format_next_header >> 16;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
636 s->inbuf[2] = s->free_format_next_header >> 8;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
637 s->inbuf[3] = s->free_format_next_header;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
638 s->inbuf_ptr = s->inbuf + 4;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
639 s->free_format_next_header = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
640 goto got_header;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
641 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
642 /* no header seen : find one. We need at least MPA_HEADER_SIZE
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
643 bytes to parse it */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
644 len = MPA_HEADER_SIZE - len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
645 if (len > buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
646 len = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
647 if (len > 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
648 memcpy(s->inbuf_ptr, buf_ptr, len);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
649 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
650 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
651 s->inbuf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
652 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
653 if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
654 got_header:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
655 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
656 (s->inbuf[2] << 8) | s->inbuf[3];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
657
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
658 ret = mpa_decode_header(avctx, header);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
659 if (ret < 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
660 /* no sync found : move by one byte (inefficient, but simple!) */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
661 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
662 s->inbuf_ptr--;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
663 dprintf("skip %x\n", header);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
664 /* reset free format frame size to give a chance
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
665 to get a new bitrate */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
666 s->free_format_frame_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
667 } else {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
668 s->frame_size = ret;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
669 #if 0
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
670 /* free format: prepare to compute frame size */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
671 if (decode_header(s, header) == 1) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
672 s->frame_size = -1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
673 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
674 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
675 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
676 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
677 } else
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
678 #if 0
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
679 if (s->frame_size == -1) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
680 /* free format : find next sync to compute frame size */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
681 len = MPA_MAX_CODED_FRAME_SIZE - len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
682 if (len > buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
683 len = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
684 if (len == 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
685 /* frame too long: resync */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
686 s->frame_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
687 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
688 s->inbuf_ptr--;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
689 } else {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
690 uint8_t *p, *pend;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
691 uint32_t header1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
692 int padding;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
693
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
694 memcpy(s->inbuf_ptr, buf_ptr, len);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
695 /* check for header */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
696 p = s->inbuf_ptr - 3;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
697 pend = s->inbuf_ptr + len - 4;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
698 while (p <= pend) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
699 header = (p[0] << 24) | (p[1] << 16) |
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
700 (p[2] << 8) | p[3];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
701 header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
702 (s->inbuf[2] << 8) | s->inbuf[3];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
703 /* check with high probability that we have a
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
704 valid header */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
705 if ((header & SAME_HEADER_MASK) ==
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
706 (header1 & SAME_HEADER_MASK)) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
707 /* header found: update pointers */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
708 len = (p + 4) - s->inbuf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
709 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
710 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
711 s->inbuf_ptr = p;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
712 /* compute frame size */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
713 s->free_format_next_header = header;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
714 s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
715 padding = (header1 >> 9) & 1;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
716 if (s->layer == 1)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
717 s->free_format_frame_size -= padding * 4;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
718 else
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
719 s->free_format_frame_size -= padding;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
720 dprintf("free frame size=%d padding=%d\n",
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
721 s->free_format_frame_size, padding);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
722 decode_header(s, header1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
723 goto next_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
724 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
725 p++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
726 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
727 /* not found: simply increase pointers */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
728 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
729 s->inbuf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
730 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
731 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
732 } else
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
733 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
734 if (len < s->frame_size) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
735 if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
736 s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
737 len = s->frame_size - len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
738 if (len > buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
739 len = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
740 memcpy(s->inbuf_ptr, buf_ptr, len);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
741 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
742 s->inbuf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
743 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
744 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
745 // next_data:
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
746 if (s->frame_size > 0 &&
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
747 (s->inbuf_ptr - s->inbuf) >= s->frame_size) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
748 *poutbuf = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
749 *poutbuf_size = s->inbuf_ptr - s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
750 s->inbuf_ptr = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
751 s->frame_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
752 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
753 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
754 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
755 return buf_ptr - buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
756 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
757
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
758 #ifdef CONFIG_AC3
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
759 extern int a52_syncinfo (const uint8_t * buf, int * flags,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
760 int * sample_rate, int * bit_rate);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
761
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
762 typedef struct AC3ParseContext {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
763 uint8_t inbuf[4096]; /* input buffer */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
764 uint8_t *inbuf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
765 int frame_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
766 int flags;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
767 } AC3ParseContext;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
768
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
769 #define AC3_HEADER_SIZE 7
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
770 #define A52_LFE 16
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
771
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
772 static int ac3_parse_init(AVCodecParserContext *s1)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
773 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
774 AC3ParseContext *s = s1->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
775 s->inbuf_ptr = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
776 return 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
777 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
778
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
779 static int ac3_parse(AVCodecParserContext *s1,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
780 AVCodecContext *avctx,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
781 uint8_t **poutbuf, int *poutbuf_size,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
782 const uint8_t *buf, int buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
783 {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
784 AC3ParseContext *s = s1->priv_data;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
785 const uint8_t *buf_ptr;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
786 int len, sample_rate, bit_rate;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
787 static const int ac3_channels[8] = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
788 2, 1, 2, 3, 3, 4, 4, 5
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
789 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
790
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
791 *poutbuf = NULL;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
792 *poutbuf_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
793
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
794 buf_ptr = buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
795 while (buf_size > 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
796 len = s->inbuf_ptr - s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
797 if (s->frame_size == 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
798 /* no header seen : find one. We need at least 7 bytes to parse it */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
799 len = AC3_HEADER_SIZE - len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
800 if (len > buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
801 len = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
802 memcpy(s->inbuf_ptr, buf_ptr, len);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
803 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
804 s->inbuf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
805 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
806 if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
807 len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
808 if (len == 0) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
809 /* no sync found : move by one byte (inefficient, but simple!) */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
810 memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
811 s->inbuf_ptr--;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
812 } else {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
813 s->frame_size = len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
814 /* update codec info */
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
815 avctx->sample_rate = sample_rate;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
816 avctx->channels = ac3_channels[s->flags & 7];
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
817 if (s->flags & A52_LFE)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
818 avctx->channels++;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
819 avctx->bit_rate = bit_rate;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
820 avctx->frame_size = 6 * 256;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
821 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
822 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
823 } else if (len < s->frame_size) {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
824 len = s->frame_size - len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
825 if (len > buf_size)
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
826 len = buf_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
827
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
828 memcpy(s->inbuf_ptr, buf_ptr, len);
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
829 buf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
830 s->inbuf_ptr += len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
831 buf_size -= len;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
832 } else {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
833 *poutbuf = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
834 *poutbuf_size = s->frame_size;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
835 s->inbuf_ptr = s->inbuf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
836 s->frame_size = 0;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
837 break;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
838 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
839 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
840 return buf_ptr - buf;
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
841 }
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
842 #endif
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
843
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
844 AVCodecParser mpegvideo_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
845 { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
846 sizeof(ParseContext1),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
847 NULL,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
848 mpegvideo_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
849 mpegvideo_parse_close,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
850 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
851
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
852 AVCodecParser mpeg4video_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
853 { CODEC_ID_MPEG4 },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
854 sizeof(ParseContext1),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
855 mpeg4video_parse_init,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
856 mpeg4video_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
857 mpegvideo_parse_close,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
858 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
859
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
860 AVCodecParser h263_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
861 { CODEC_ID_H263 },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
862 sizeof(ParseContext1),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
863 NULL,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
864 h263_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
865 mpegvideo_parse_close,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
866 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
867
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
868 AVCodecParser h264_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
869 { CODEC_ID_H264 },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
870 sizeof(ParseContext1),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
871 NULL,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
872 h264_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
873 mpegvideo_parse_close,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
874 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
875
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
876 AVCodecParser mpegaudio_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
877 { CODEC_ID_MP2, CODEC_ID_MP3 },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
878 sizeof(MpegAudioParseContext),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
879 mpegaudio_parse_init,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
880 mpegaudio_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
881 NULL,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
882 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
883
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
884 #ifdef CONFIG_AC3
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
885 AVCodecParser ac3_parser = {
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
886 { CODEC_ID_AC3 },
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
887 sizeof(AC3ParseContext),
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
888 ac3_parse_init,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
889 ac3_parse,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
890 NULL,
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
891 };
0279c6c61f11 new audio/video parser API
bellard
parents:
diff changeset
892 #endif