Mercurial > libavformat.hg
annotate raw.c @ 558:89bd76208427 libavformat
100l (forgoten seeking functions)
author | michael |
---|---|
date | Mon, 11 Oct 2004 23:53:53 +0000 |
parents | 558a093b04db |
children | 23b915bb10f5 |
rev | line source |
---|---|
0 | 1 /* |
2 * RAW encoder and decoder | |
3 * Copyright (c) 2001 Fabrice Bellard. | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 #include "avformat.h" | |
20 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
21 #ifdef CONFIG_ENCODERS |
0 | 22 /* simple formats */ |
64 | 23 static int raw_write_header(struct AVFormatContext *s) |
0 | 24 { |
25 return 0; | |
26 } | |
27 | |
468 | 28 static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt) |
0 | 29 { |
468 | 30 put_buffer(&s->pb, pkt->data, pkt->size); |
0 | 31 put_flush_packet(&s->pb); |
32 return 0; | |
33 } | |
34 | |
64 | 35 static int raw_write_trailer(struct AVFormatContext *s) |
0 | 36 { |
37 return 0; | |
38 } | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
39 #endif //CONFIG_ENCODERS |
0 | 40 |
41 /* raw input */ | |
65 | 42 static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
0 | 43 { |
44 AVStream *st; | |
45 int id; | |
46 | |
47 st = av_new_stream(s, 0); | |
48 if (!st) | |
49 return AVERROR_NOMEM; | |
50 if (ap) { | |
51 id = s->iformat->value; | |
52 if (id == CODEC_ID_RAWVIDEO) { | |
53 st->codec.codec_type = CODEC_TYPE_VIDEO; | |
54 } else { | |
55 st->codec.codec_type = CODEC_TYPE_AUDIO; | |
56 } | |
57 st->codec.codec_id = id; | |
58 | |
59 switch(st->codec.codec_type) { | |
60 case CODEC_TYPE_AUDIO: | |
61 st->codec.sample_rate = ap->sample_rate; | |
62 st->codec.channels = ap->channels; | |
63 break; | |
64 case CODEC_TYPE_VIDEO: | |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
65 st->codec.frame_rate = ap->frame_rate; |
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
66 st->codec.frame_rate_base = ap->frame_rate_base; |
0 | 67 st->codec.width = ap->width; |
68 st->codec.height = ap->height; | |
128 | 69 st->codec.pix_fmt = ap->pix_fmt; |
0 | 70 break; |
71 default: | |
72 return -1; | |
73 } | |
74 } else { | |
75 return -1; | |
76 } | |
77 return 0; | |
78 } | |
79 | |
80 #define RAW_PACKET_SIZE 1024 | |
81 | |
64 | 82 static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 83 { |
84 int ret, size; | |
28 | 85 // AVStream *st = s->streams[0]; |
0 | 86 |
87 size= RAW_PACKET_SIZE; | |
88 | |
89 if (av_new_packet(pkt, size) < 0) | |
482 | 90 return AVERROR_IO; |
0 | 91 |
92 pkt->stream_index = 0; | |
93 ret = get_buffer(&s->pb, pkt->data, size); | |
94 if (ret <= 0) { | |
95 av_free_packet(pkt); | |
482 | 96 return AVERROR_IO; |
0 | 97 } |
98 /* note: we need to modify the packet size here to handle the last | |
99 packet */ | |
100 pkt->size = ret; | |
101 return ret; | |
102 } | |
103 | |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
104 static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
105 { |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
106 int ret, size; |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
107 |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
108 size = RAW_PACKET_SIZE; |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
109 |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
110 if (av_new_packet(pkt, size) < 0) |
482 | 111 return AVERROR_IO; |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
112 |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
113 pkt->stream_index = 0; |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
114 ret = get_partial_buffer(&s->pb, pkt->data, size); |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
115 if (ret <= 0) { |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
116 av_free_packet(pkt); |
482 | 117 return AVERROR_IO; |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
118 } |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
119 pkt->size = ret; |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
120 return ret; |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
121 } |
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
122 |
64 | 123 static int raw_read_close(AVFormatContext *s) |
0 | 124 { |
125 return 0; | |
126 } | |
127 | |
306 | 128 int pcm_read_seek(AVFormatContext *s, |
558 | 129 int stream_index, int64_t timestamp, int flags) |
306 | 130 { |
131 AVStream *st; | |
132 int block_align, byte_rate; | |
133 int64_t pos; | |
134 | |
135 st = s->streams[0]; | |
136 switch(st->codec.codec_id) { | |
137 case CODEC_ID_PCM_S16LE: | |
138 case CODEC_ID_PCM_S16BE: | |
139 case CODEC_ID_PCM_U16LE: | |
140 case CODEC_ID_PCM_U16BE: | |
141 block_align = 2 * st->codec.channels; | |
142 byte_rate = block_align * st->codec.sample_rate; | |
143 break; | |
144 case CODEC_ID_PCM_S8: | |
145 case CODEC_ID_PCM_U8: | |
146 case CODEC_ID_PCM_MULAW: | |
147 case CODEC_ID_PCM_ALAW: | |
148 block_align = st->codec.channels; | |
149 byte_rate = block_align * st->codec.sample_rate; | |
150 break; | |
151 default: | |
152 block_align = st->codec.block_align; | |
153 byte_rate = st->codec.bit_rate / 8; | |
154 break; | |
155 } | |
156 | |
157 if (block_align <= 0 || byte_rate <= 0) | |
158 return -1; | |
159 | |
160 /* compute the position by aligning it to block_align */ | |
558 | 161 pos = av_rescale_rnd(timestamp * byte_rate, |
162 st->time_base.num, | |
163 st->time_base.den * (int64_t)block_align, | |
164 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP); | |
165 pos *= block_align; | |
306 | 166 |
167 /* recompute exact position */ | |
464 | 168 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); |
306 | 169 url_fseek(&s->pb, pos + s->data_offset, SEEK_SET); |
170 return 0; | |
171 } | |
172 | |
63 | 173 /* ac3 read */ |
174 static int ac3_read_header(AVFormatContext *s, | |
175 AVFormatParameters *ap) | |
176 { | |
177 AVStream *st; | |
178 | |
179 st = av_new_stream(s, 0); | |
180 if (!st) | |
181 return AVERROR_NOMEM; | |
182 | |
183 st->codec.codec_type = CODEC_TYPE_AUDIO; | |
184 st->codec.codec_id = CODEC_ID_AC3; | |
306 | 185 st->need_parsing = 1; |
63 | 186 /* the parameters will be extracted from the compressed bitstream */ |
187 return 0; | |
188 } | |
189 | |
496
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
190 /* dts read */ |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
191 static int dts_read_header(AVFormatContext *s, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
192 AVFormatParameters *ap) |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
193 { |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
194 AVStream *st; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
195 |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
196 st = av_new_stream(s, 0); |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
197 if (!st) |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
198 return AVERROR_NOMEM; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
199 |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
200 st->codec.codec_type = CODEC_TYPE_AUDIO; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
201 st->codec.codec_id = CODEC_ID_DTS; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
202 st->need_parsing = 1; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
203 /* the parameters will be extracted from the compressed bitstream */ |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
204 return 0; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
205 } |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
206 |
0 | 207 /* mpeg1/h263 input */ |
208 static int video_read_header(AVFormatContext *s, | |
209 AVFormatParameters *ap) | |
210 { | |
211 AVStream *st; | |
212 | |
213 st = av_new_stream(s, 0); | |
214 if (!st) | |
215 return AVERROR_NOMEM; | |
216 | |
217 st->codec.codec_type = CODEC_TYPE_VIDEO; | |
218 st->codec.codec_id = s->iformat->value; | |
306 | 219 st->need_parsing = 1; |
220 | |
0 | 221 /* for mjpeg, specify frame rate */ |
222 /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ | |
306 | 223 if (st->codec.codec_id == CODEC_ID_MJPEG || |
224 st->codec.codec_id == CODEC_ID_MPEG4) { | |
225 if (ap && ap->frame_rate) { | |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
226 st->codec.frame_rate = ap->frame_rate; |
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
227 st->codec.frame_rate_base = ap->frame_rate_base; |
0 | 228 } else { |
85
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
229 st->codec.frame_rate = 25; |
25062c9b1f86
per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents:
65
diff
changeset
|
230 st->codec.frame_rate_base = 1; |
0 | 231 } |
232 } | |
233 return 0; | |
234 } | |
235 | |
236 #define SEQ_START_CODE 0x000001b3 | |
237 #define GOP_START_CODE 0x000001b8 | |
238 #define PICTURE_START_CODE 0x00000100 | |
239 | |
240 /* XXX: improve that by looking at several start codes */ | |
241 static int mpegvideo_probe(AVProbeData *p) | |
242 { | |
49 | 243 int code; |
244 const uint8_t *d; | |
0 | 245 |
246 /* we search the first start code. If it is a sequence, gop or | |
247 picture start code then we decide it is an mpeg video | |
248 stream. We do not send highest value to give a chance to mpegts */ | |
49 | 249 /* NOTE: the search range was restricted to avoid too many false |
250 detections */ | |
251 | |
252 if (p->buf_size < 6) | |
253 return 0; | |
254 d = p->buf; | |
255 code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]); | |
256 if ((code & 0xffffff00) == 0x100) { | |
257 if (code == SEQ_START_CODE || | |
258 code == GOP_START_CODE || | |
259 code == PICTURE_START_CODE) | |
260 return 50 - 1; | |
261 else | |
262 return 0; | |
0 | 263 } |
264 return 0; | |
265 } | |
266 | |
135
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
267 static int h263_probe(AVProbeData *p) |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
268 { |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
269 int code; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
270 const uint8_t *d; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
271 |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
272 if (p->buf_size < 6) |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
273 return 0; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
274 d = p->buf; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
275 code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2); |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
276 if (code == 0x20) { |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
277 return 50; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
278 } |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
279 return 0; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
280 } |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
281 |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
282 static int h261_probe(AVProbeData *p) |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
283 { |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
284 int code; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
285 const uint8_t *d; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
286 |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
287 if (p->buf_size < 6) |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
288 return 0; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
289 d = p->buf; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
290 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4); |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
291 if (code == 0x10) { |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
292 return 50; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
293 } |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
294 return 0; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
295 } |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
296 |
0 | 297 AVInputFormat ac3_iformat = { |
298 "ac3", | |
299 "raw ac3", | |
300 0, | |
301 NULL, | |
63 | 302 ac3_read_header, |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
303 raw_read_partial_packet, |
0 | 304 raw_read_close, |
305 .extensions = "ac3", | |
306 }; | |
307 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
308 #ifdef CONFIG_ENCODERS |
0 | 309 AVOutputFormat ac3_oformat = { |
310 "ac3", | |
311 "raw ac3", | |
312 "audio/x-ac3", | |
313 "ac3", | |
314 0, | |
315 CODEC_ID_AC3, | |
316 0, | |
317 raw_write_header, | |
318 raw_write_packet, | |
319 raw_write_trailer, | |
320 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
321 #endif //CONFIG_ENCODERS |
0 | 322 |
496
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
323 AVInputFormat dts_iformat = { |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
324 "dts", |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
325 "raw dts", |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
326 0, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
327 NULL, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
328 dts_read_header, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
329 raw_read_partial_packet, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
330 raw_read_close, |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
331 .extensions = "dts", |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
332 }; |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
333 |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
334 AVInputFormat h261_iformat = { |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
335 "h261", |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
336 "raw h261", |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
337 0, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
338 h261_probe, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
339 video_read_header, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
340 raw_read_partial_packet, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
341 raw_read_close, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
342 .extensions = "h261", |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
343 .value = CODEC_ID_H261, |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
344 }; |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
345 |
135
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
346 AVInputFormat h263_iformat = { |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
347 "h263", |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
348 "raw h263", |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
349 0, |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
350 h263_probe, |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
351 video_read_header, |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
352 raw_read_partial_packet, |
135
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
353 raw_read_close, |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
354 // .extensions = "h263", //FIXME remove after writing mpeg4_probe |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
355 .value = CODEC_ID_H263, |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
356 }; |
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
357 |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
358 #ifdef CONFIG_ENCODERS |
0 | 359 AVOutputFormat h263_oformat = { |
360 "h263", | |
361 "raw h263", | |
362 "video/x-h263", | |
363 "h263", | |
364 0, | |
365 0, | |
366 CODEC_ID_H263, | |
367 raw_write_header, | |
368 raw_write_packet, | |
369 raw_write_trailer, | |
370 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
371 #endif //CONFIG_ENCODERS |
0 | 372 |
373 AVInputFormat m4v_iformat = { | |
374 "m4v", | |
375 "raw MPEG4 video format", | |
376 0, | |
377 NULL /*mpegvideo_probe*/, | |
378 video_read_header, | |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
379 raw_read_partial_packet, |
0 | 380 raw_read_close, |
381 .extensions = "m4v", //FIXME remove after writing mpeg4_probe | |
382 .value = CODEC_ID_MPEG4, | |
383 }; | |
384 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
385 #ifdef CONFIG_ENCODERS |
0 | 386 AVOutputFormat m4v_oformat = { |
387 "m4v", | |
388 "raw MPEG4 video format", | |
389 NULL, | |
390 "m4v", | |
391 0, | |
392 CODEC_ID_NONE, | |
393 CODEC_ID_MPEG4, | |
394 raw_write_header, | |
395 raw_write_packet, | |
396 raw_write_trailer, | |
397 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
398 #endif //CONFIG_ENCODERS |
0 | 399 |
100 | 400 AVInputFormat h264_iformat = { |
401 "h264", | |
402 "raw H264 video format", | |
403 0, | |
404 NULL /*mpegvideo_probe*/, | |
405 video_read_header, | |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
406 raw_read_partial_packet, |
100 | 407 raw_read_close, |
408 .extensions = "h26l,h264", //FIXME remove after writing mpeg4_probe | |
409 .value = CODEC_ID_H264, | |
410 }; | |
411 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
412 #ifdef CONFIG_ENCODERS |
100 | 413 AVOutputFormat h264_oformat = { |
414 "h264", | |
415 "raw H264 video format", | |
416 NULL, | |
417 "h264", | |
418 0, | |
419 CODEC_ID_NONE, | |
420 CODEC_ID_H264, | |
421 raw_write_header, | |
422 raw_write_packet, | |
423 raw_write_trailer, | |
424 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
425 #endif //CONFIG_ENCODERS |
100 | 426 |
0 | 427 AVInputFormat mpegvideo_iformat = { |
428 "mpegvideo", | |
429 "MPEG video", | |
430 0, | |
431 mpegvideo_probe, | |
432 video_read_header, | |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
433 raw_read_partial_packet, |
0 | 434 raw_read_close, |
435 .value = CODEC_ID_MPEG1VIDEO, | |
436 }; | |
437 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
438 #ifdef CONFIG_ENCODERS |
0 | 439 AVOutputFormat mpeg1video_oformat = { |
440 "mpeg1video", | |
441 "MPEG video", | |
442 "video/x-mpeg", | |
443 "mpg,mpeg", | |
444 0, | |
445 0, | |
446 CODEC_ID_MPEG1VIDEO, | |
447 raw_write_header, | |
448 raw_write_packet, | |
449 raw_write_trailer, | |
450 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
451 #endif //CONFIG_ENCODERS |
0 | 452 |
453 AVInputFormat mjpeg_iformat = { | |
454 "mjpeg", | |
455 "MJPEG video", | |
456 0, | |
457 NULL, | |
458 video_read_header, | |
389
e14fcd57ad2f
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
michael
parents:
306
diff
changeset
|
459 raw_read_partial_packet, |
0 | 460 raw_read_close, |
461 .extensions = "mjpg,mjpeg", | |
462 .value = CODEC_ID_MJPEG, | |
463 }; | |
464 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
465 #ifdef CONFIG_ENCODERS |
0 | 466 AVOutputFormat mjpeg_oformat = { |
467 "mjpeg", | |
468 "MJPEG video", | |
469 "video/x-mjpeg", | |
470 "mjpg,mjpeg", | |
471 0, | |
472 0, | |
473 CODEC_ID_MJPEG, | |
474 raw_write_header, | |
475 raw_write_packet, | |
476 raw_write_trailer, | |
477 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
478 #endif //CONFIG_ENCODERS |
0 | 479 |
480 /* pcm formats */ | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
481 |
306 | 482 #define PCMINPUTDEF(name, long_name, ext, codec) \ |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
483 AVInputFormat pcm_ ## name ## _iformat = {\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
484 #name,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
485 long_name,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
486 0,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
487 NULL,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
488 raw_read_header,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
489 raw_read_packet,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
490 raw_read_close,\ |
306 | 491 pcm_read_seek,\ |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
492 .extensions = ext,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
493 .value = codec,\ |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
494 }; |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
495 |
306 | 496 #if !defined(CONFIG_ENCODERS) && defined(CONFIG_DECODERS) |
497 | |
498 #define PCMDEF(name, long_name, ext, codec) \ | |
499 PCMINPUTDEF(name, long_name, ext, codec) | |
500 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
501 #else |
0 | 502 |
503 #define PCMDEF(name, long_name, ext, codec) \ | |
306 | 504 PCMINPUTDEF(name, long_name, ext, codec)\ |
0 | 505 \ |
506 AVOutputFormat pcm_ ## name ## _oformat = {\ | |
507 #name,\ | |
508 long_name,\ | |
509 NULL,\ | |
510 ext,\ | |
511 0,\ | |
512 codec,\ | |
513 0,\ | |
514 raw_write_header,\ | |
515 raw_write_packet,\ | |
516 raw_write_trailer,\ | |
517 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
518 #endif //CONFIG_ENCODERS |
0 | 519 |
520 #ifdef WORDS_BIGENDIAN | |
521 #define BE_DEF(s) s | |
522 #define LE_DEF(s) NULL | |
523 #else | |
524 #define BE_DEF(s) NULL | |
525 #define LE_DEF(s) s | |
526 #endif | |
527 | |
528 | |
529 PCMDEF(s16le, "pcm signed 16 bit little endian format", | |
530 LE_DEF("sw"), CODEC_ID_PCM_S16LE) | |
531 | |
532 PCMDEF(s16be, "pcm signed 16 bit big endian format", | |
533 BE_DEF("sw"), CODEC_ID_PCM_S16BE) | |
534 | |
535 PCMDEF(u16le, "pcm unsigned 16 bit little endian format", | |
536 LE_DEF("uw"), CODEC_ID_PCM_U16LE) | |
537 | |
538 PCMDEF(u16be, "pcm unsigned 16 bit big endian format", | |
539 BE_DEF("uw"), CODEC_ID_PCM_U16BE) | |
540 | |
541 PCMDEF(s8, "pcm signed 8 bit format", | |
542 "sb", CODEC_ID_PCM_S8) | |
543 | |
544 PCMDEF(u8, "pcm unsigned 8 bit format", | |
545 "ub", CODEC_ID_PCM_U8) | |
546 | |
547 PCMDEF(mulaw, "pcm mu law format", | |
548 "ul", CODEC_ID_PCM_MULAW) | |
549 | |
550 PCMDEF(alaw, "pcm A law format", | |
551 "al", CODEC_ID_PCM_ALAW) | |
552 | |
64 | 553 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 554 { |
555 int packet_size, ret, width, height; | |
556 AVStream *st = s->streams[0]; | |
557 | |
558 width = st->codec.width; | |
559 height = st->codec.height; | |
560 | |
128 | 561 packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); |
562 if (packet_size < 0) | |
537 | 563 return -1; |
0 | 564 |
565 if (av_new_packet(pkt, packet_size) < 0) | |
482 | 566 return AVERROR_IO; |
0 | 567 |
568 pkt->stream_index = 0; | |
569 #if 0 | |
570 /* bypass buffered I/O */ | |
571 ret = url_read(url_fileno(&s->pb), pkt->data, pkt->size); | |
572 #else | |
573 ret = get_buffer(&s->pb, pkt->data, pkt->size); | |
574 #endif | |
575 if (ret != pkt->size) { | |
576 av_free_packet(pkt); | |
482 | 577 return AVERROR_IO; |
0 | 578 } else { |
579 return 0; | |
580 } | |
581 } | |
582 | |
583 AVInputFormat rawvideo_iformat = { | |
584 "rawvideo", | |
585 "raw video format", | |
586 0, | |
587 NULL, | |
588 raw_read_header, | |
589 rawvideo_read_packet, | |
590 raw_read_close, | |
591 .extensions = "yuv", | |
592 .value = CODEC_ID_RAWVIDEO, | |
593 }; | |
594 | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
595 #ifdef CONFIG_ENCODERS |
0 | 596 AVOutputFormat rawvideo_oformat = { |
597 "rawvideo", | |
598 "raw video format", | |
599 NULL, | |
600 "yuv", | |
601 0, | |
602 CODEC_ID_NONE, | |
603 CODEC_ID_RAWVIDEO, | |
604 raw_write_header, | |
605 raw_write_packet, | |
606 raw_write_trailer, | |
607 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
608 #endif //CONFIG_ENCODERS |
0 | 609 |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
610 #ifdef CONFIG_ENCODERS |
468 | 611 static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt) |
0 | 612 { |
613 return 0; | |
614 } | |
615 | |
616 AVOutputFormat null_oformat = { | |
617 "null", | |
618 "null video format", | |
619 NULL, | |
620 NULL, | |
621 0, | |
622 #ifdef WORDS_BIGENDIAN | |
623 CODEC_ID_PCM_S16BE, | |
624 #else | |
625 CODEC_ID_PCM_S16LE, | |
626 #endif | |
627 CODEC_ID_RAWVIDEO, | |
628 raw_write_header, | |
629 null_write_packet, | |
630 raw_write_trailer, | |
631 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE, | |
632 }; | |
277
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
633 #endif //CONFIG_ENCODERS |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
634 |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
635 #ifndef CONFIG_ENCODERS |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
636 #define av_register_output_format(format) |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
637 #endif |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
638 #ifndef CONFIG_DECODERS |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
639 #define av_register_input_format(format) |
a313e1080322
disable encoders where appropriate (patch courtesy of BERO
melanson
parents:
241
diff
changeset
|
640 #endif |
0 | 641 |
642 int raw_init(void) | |
643 { | |
644 av_register_input_format(&ac3_iformat); | |
645 av_register_output_format(&ac3_oformat); | |
646 | |
496
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
647 av_register_input_format(&dts_iformat); |
112057e05179
libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents:
483
diff
changeset
|
648 |
473
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
649 av_register_input_format(&h261_iformat); |
e0a66a870b7f
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
468
diff
changeset
|
650 |
135
56590088f801
truncated h263 decoding support / H263-ES "demuxer"
michaelni
parents:
128
diff
changeset
|
651 av_register_input_format(&h263_iformat); |
0 | 652 av_register_output_format(&h263_oformat); |
653 | |
654 av_register_input_format(&m4v_iformat); | |
655 av_register_output_format(&m4v_oformat); | |
100 | 656 |
657 av_register_input_format(&h264_iformat); | |
658 av_register_output_format(&h264_oformat); | |
0 | 659 |
660 av_register_input_format(&mpegvideo_iformat); | |
661 av_register_output_format(&mpeg1video_oformat); | |
662 | |
663 av_register_input_format(&mjpeg_iformat); | |
664 av_register_output_format(&mjpeg_oformat); | |
665 | |
666 av_register_input_format(&pcm_s16le_iformat); | |
667 av_register_output_format(&pcm_s16le_oformat); | |
668 av_register_input_format(&pcm_s16be_iformat); | |
669 av_register_output_format(&pcm_s16be_oformat); | |
670 av_register_input_format(&pcm_u16le_iformat); | |
671 av_register_output_format(&pcm_u16le_oformat); | |
672 av_register_input_format(&pcm_u16be_iformat); | |
673 av_register_output_format(&pcm_u16be_oformat); | |
674 av_register_input_format(&pcm_s8_iformat); | |
675 av_register_output_format(&pcm_s8_oformat); | |
676 av_register_input_format(&pcm_u8_iformat); | |
677 av_register_output_format(&pcm_u8_oformat); | |
678 av_register_input_format(&pcm_mulaw_iformat); | |
679 av_register_output_format(&pcm_mulaw_oformat); | |
680 av_register_input_format(&pcm_alaw_iformat); | |
681 av_register_output_format(&pcm_alaw_oformat); | |
682 | |
683 av_register_input_format(&rawvideo_iformat); | |
684 av_register_output_format(&rawvideo_oformat); | |
685 | |
686 av_register_output_format(&null_oformat); | |
687 return 0; | |
688 } |