indent
[libav.git] / libavformat / raw.c
CommitLineData
115329f1 1/*
7fbde343 2 * RAW muxer and demuxer
19720f15 3 * Copyright (c) 2001 Fabrice Bellard.
84c63c01 4 * Copyright (c) 2005 Alex Beregszaszi
de6d9b64 5 *
b78e7197
DB
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
19720f15
FB
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
b78e7197 11 * version 2.1 of the License, or (at your option) any later version.
de6d9b64 12 *
b78e7197 13 * FFmpeg is distributed in the hope that it will be useful,
de6d9b64 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19720f15
FB
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
de6d9b64 17 *
19720f15 18 * You should have received a copy of the GNU Lesser General Public
b78e7197 19 * License along with FFmpeg; if not, write to the Free Software
5509bffa 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
de6d9b64 21 */
245976da
DB
22
23#include "libavutil/crc.h"
24#include "libavcodec/ac3_parser.h"
25#include "libavcodec/bitstream.h"
26#include "libavcodec/bytestream.h"
de6d9b64 27#include "avformat.h"
7241a6bb 28#include "raw.h"
de6d9b64 29
a9e35095 30#ifdef CONFIG_MUXERS
de6d9b64 31/* simple formats */
ce1d2a95
JR
32static int flac_write_header(struct AVFormatContext *s)
33{
34 static const uint8_t header[8] = {
35 0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22
36 };
37 uint8_t *streaminfo = s->streams[0]->codec->extradata;
38 int len = s->streams[0]->codec->extradata_size;
39 if(streaminfo != NULL && len > 0) {
899681cd
BA
40 put_buffer(s->pb, header, 8);
41 put_buffer(s->pb, streaminfo, len);
ce1d2a95
JR
42 }
43 return 0;
44}
45
13dec857
VS
46
47static int roq_write_header(struct AVFormatContext *s)
48{
49 static const uint8_t header[] = {
50 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
51 };
52
899681cd
BA
53 put_buffer(s->pb, header, 8);
54 put_flush_packet(s->pb);
13dec857
VS
55
56 return 0;
57}
58
76d32428
DB
59static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
60{
61 return 0;
62}
63
e928649b 64static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
de6d9b64 65{
899681cd
BA
66 put_buffer(s->pb, pkt->data, pkt->size);
67 put_flush_packet(s->pb);
de6d9b64
FB
68 return 0;
69}
a9e35095 70#endif //CONFIG_MUXERS
de6d9b64
FB
71
72/* raw input */
0c1a9eda 73static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
de6d9b64
FB
74{
75 AVStream *st;
c9a65ca8 76 int id;
de6d9b64 77
c9a65ca8 78 st = av_new_stream(s, 0);
de6d9b64 79 if (!st)
769e10f0 80 return AVERROR(ENOMEM);
c04c3282 81
c9a65ca8
FB
82 id = s->iformat->value;
83 if (id == CODEC_ID_RAWVIDEO) {
01f4895c 84 st->codec->codec_type = CODEC_TYPE_VIDEO;
de6d9b64 85 } else {
01f4895c 86 st->codec->codec_type = CODEC_TYPE_AUDIO;
de6d9b64 87 }
01f4895c 88 st->codec->codec_id = id;
c9a65ca8 89
01f4895c 90 switch(st->codec->codec_type) {
de6d9b64 91 case CODEC_TYPE_AUDIO:
01f4895c
MN
92 st->codec->sample_rate = ap->sample_rate;
93 st->codec->channels = ap->channels;
94 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
de6d9b64
FB
95 break;
96 case CODEC_TYPE_VIDEO:
9de0be61
MN
97 if(ap->time_base.num)
98 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
99 else
100 av_set_pts_info(st, 64, 1, 25);
01f4895c
MN
101 st->codec->width = ap->width;
102 st->codec->height = ap->height;
103 st->codec->pix_fmt = ap->pix_fmt;
104 if(st->codec->pix_fmt == PIX_FMT_NONE)
105 st->codec->pix_fmt= PIX_FMT_YUV420P;
de6d9b64
FB
106 break;
107 default:
27e084bd 108 return -1;
de6d9b64 109 }
de6d9b64
FB
110 return 0;
111}
112
2e93e3aa 113#define RAW_PACKET_SIZE 1024
de6d9b64 114
5c91a675 115static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 116{
f5b41031 117 int ret, size, bps;
2a6874fd 118 // AVStream *st = s->streams[0];
115329f1 119
231dd3f3 120 size= RAW_PACKET_SIZE;
de6d9b64 121
899681cd 122 ret= av_get_packet(s->pb, pkt, size);
de6d9b64
FB
123
124 pkt->stream_index = 0;
2e93e3aa 125 if (ret <= 0) {
6f3e0b21 126 return AVERROR(EIO);
2e93e3aa
FB
127 }
128 /* note: we need to modify the packet size here to handle the last
129 packet */
130 pkt->size = ret;
f5b41031
MN
131
132 bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
133 assert(bps); // if false there IS a bug elsewhere (NOT in this function)
134 pkt->dts=
135 pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
136
de6d9b64
FB
137 return ret;
138}
139
e15dec10
LS
140static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
141{
142 int ret, size;
143
144 size = RAW_PACKET_SIZE;
145
146 if (av_new_packet(pkt, size) < 0)
6f3e0b21 147 return AVERROR(EIO);
115329f1 148
899681cd 149 pkt->pos= url_ftell(s->pb);
e15dec10 150 pkt->stream_index = 0;
899681cd 151 ret = get_partial_buffer(s->pb, pkt->data, size);
e15dec10
LS
152 if (ret <= 0) {
153 av_free_packet(pkt);
6f3e0b21 154 return AVERROR(EIO);
e15dec10
LS
155 }
156 pkt->size = ret;
157 return ret;
158}
159
76d32428
DB
160static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
161{
162 int packet_size, ret, width, height;
163 AVStream *st = s->streams[0];
164
165 width = st->codec->width;
166 height = st->codec->height;
167
168 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
169 if (packet_size < 0)
170 return -1;
171
172 ret= av_get_packet(s->pb, pkt, packet_size);
173 pkt->pts=
174 pkt->dts= pkt->pos / packet_size;
175
176 pkt->stream_index = 0;
177 if (ret != packet_size) {
178 return AVERROR(EIO);
179 } else {
180 return 0;
181 }
182}
183
84c63c01
AB
184// http://www.artificis.hu/files/texts/ingenient.txt
185static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
186{
187 int ret, size, w, h, unk1, unk2;
115329f1 188
899681cd 189 if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
6f3e0b21 190 return AVERROR(EIO); // FIXME
84c63c01 191
899681cd 192 size = get_le32(s->pb);
115329f1 193
899681cd
BA
194 w = get_le16(s->pb);
195 h = get_le16(s->pb);
115329f1 196
899681cd
BA
197 url_fskip(s->pb, 8); // zero + size (padded?)
198 url_fskip(s->pb, 2);
199 unk1 = get_le16(s->pb);
200 unk2 = get_le16(s->pb);
201 url_fskip(s->pb, 22); // ascii timestamp
115329f1 202
84c63c01 203 av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
bb270c08 204 size, w, h, unk1, unk2);
84c63c01
AB
205
206 if (av_new_packet(pkt, size) < 0)
6f3e0b21 207 return AVERROR(EIO);
84c63c01 208
899681cd 209 pkt->pos = url_ftell(s->pb);
84c63c01 210 pkt->stream_index = 0;
899681cd 211 ret = get_buffer(s->pb, pkt->data, size);
84c63c01
AB
212 if (ret <= 0) {
213 av_free_packet(pkt);
6f3e0b21 214 return AVERROR(EIO);
84c63c01
AB
215 }
216 pkt->size = ret;
217 return ret;
218}
219
115329f1 220int pcm_read_seek(AVFormatContext *s,
7b3c1382 221 int stream_index, int64_t timestamp, int flags)
4986a429
FB
222{
223 AVStream *st;
224 int block_align, byte_rate;
225 int64_t pos;
226
227 st = s->streams[0];
708e3e7d
BC
228
229 block_align = st->codec->block_align ? st->codec->block_align :
230 (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
231 byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
232 block_align * st->codec->sample_rate;
115329f1 233
4986a429
FB
234 if (block_align <= 0 || byte_rate <= 0)
235 return -1;
236
237 /* compute the position by aligning it to block_align */
115329f1
DB
238 pos = av_rescale_rnd(timestamp * byte_rate,
239 st->time_base.num,
7b3c1382
MN
240 st->time_base.den * (int64_t)block_align,
241 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
242 pos *= block_align;
4986a429
FB
243
244 /* recompute exact position */
77405fc8 245 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
899681cd 246 url_fseek(s->pb, pos + s->data_offset, SEEK_SET);
4986a429
FB
247 return 0;
248}
249
a0af2fa4
BC
250static int audio_read_header(AVFormatContext *s,
251 AVFormatParameters *ap)
fda885c7 252{
a0af2fa4 253 AVStream *st = av_new_stream(s, 0);
fda885c7 254 if (!st)
769e10f0 255 return AVERROR(ENOMEM);
fda885c7 256 st->codec->codec_type = CODEC_TYPE_AUDIO;
a0af2fa4 257 st->codec->codec_id = s->iformat->value;
57004ff1 258 st->need_parsing = AVSTREAM_PARSE_FULL;
fda885c7
MR
259 /* the parameters will be extracted from the compressed bitstream */
260 return 0;
261}
262
de6d9b64
FB
263/* mpeg1/h263 input */
264static int video_read_header(AVFormatContext *s,
265 AVFormatParameters *ap)
266{
267 AVStream *st;
268
c9a65ca8 269 st = av_new_stream(s, 0);
de6d9b64 270 if (!st)
769e10f0 271 return AVERROR(ENOMEM);
de6d9b64 272
01f4895c
MN
273 st->codec->codec_type = CODEC_TYPE_VIDEO;
274 st->codec->codec_id = s->iformat->value;
57004ff1 275 st->need_parsing = AVSTREAM_PARSE_FULL;
4986a429 276
27e084bd 277 /* for mjpeg, specify frame rate */
755bfeab 278 /* for mpeg4 specify it too (most mpeg4 streams do not have the fixed_vop_rate set ...)*/
c04c3282 279 if (ap->time_base.num) {
80ce3254 280 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
115329f1 281 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
01f4895c 282 st->codec->codec_id == CODEC_ID_MPEG4 ||
17ac9f1c 283 st->codec->codec_id == CODEC_ID_DIRAC ||
01f4895c 284 st->codec->codec_id == CODEC_ID_H264) {
80ce3254 285 av_set_pts_info(st, 64, 1, 25);
27e084bd 286 }
80ce3254 287
de6d9b64
FB
288 return 0;
289}
290
bb270c08
DB
291#define SEQ_START_CODE 0x000001b3
292#define GOP_START_CODE 0x000001b8
293#define PICTURE_START_CODE 0x00000100
93d3e278
MN
294#define SLICE_START_CODE 0x00000101
295#define PACK_START_CODE 0x000001ba
e01dc227
MR
296#define VIDEO_ID 0x000001e0
297#define AUDIO_ID 0x000001c0
c9a65ca8 298
c9a65ca8
FB
299static int mpegvideo_probe(AVProbeData *p)
300{
93d3e278 301 uint32_t code= -1;
e01dc227 302 int pic=0, seq=0, slice=0, pspack=0, pes=0;
93d3e278
MN
303 int i;
304
305 for(i=0; i<p->buf_size; i++){
306 code = (code<<8) + p->buf[i];
307 if ((code & 0xffffff00) == 0x100) {
308 switch(code){
309 case SEQ_START_CODE: seq++; break;
310 case PICTURE_START_CODE: pic++; break;
311 case SLICE_START_CODE: slice++; break;
312 case PACK_START_CODE: pspack++; break;
313 }
e9f6c8ea
MN
314 if ((code & 0x1f0) == VIDEO_ID) pes++;
315 else if((code & 0x1e0) == AUDIO_ID) pes++;
93d3e278 316 }
c9a65ca8 317 }
e01dc227 318 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
93d3e278 319 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
c9a65ca8
FB
320 return 0;
321}
322
8f57cc5a
TV
323#define VISUAL_OBJECT_START_CODE 0x000001b5
324#define VOP_START_CODE 0x000001b6
325
326static int mpeg4video_probe(AVProbeData *probe_packet)
327{
328 uint32_t temp_buffer= -1;
5fd5d0ef 329 int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
8f57cc5a
TV
330 int i;
331
332 for(i=0; i<probe_packet->buf_size; i++){
333 temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
c21f308e
RS
334 if ((temp_buffer & 0xffffff00) != 0x100)
335 continue;
336
337 if (temp_buffer == VOP_START_CODE) VOP++;
338 else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;
339 else if (temp_buffer < 0x120) VO++;
340 else if (temp_buffer < 0x130) VOL++;
341 else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
342 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
8f57cc5a
TV
343 }
344
5fd5d0ef 345 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
8f57cc5a
TV
346 return AVPROBE_SCORE_MAX/2;
347 return 0;
348}
349
d07f9043
MN
350static int h263_probe(AVProbeData *p)
351{
352 int code;
353 const uint8_t *d;
354
d07f9043
MN
355 d = p->buf;
356 code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
357 if (code == 0x20) {
358 return 50;
359 }
360 return 0;
361}
362
c6148de2
MN
363static int h261_probe(AVProbeData *p)
364{
365 int code;
366 const uint8_t *d;
367
c6148de2
MN
368 d = p->buf;
369 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
370 if (code == 0x10) {
371 return 50;
372 }
373 return 0;
374}
375
fde8052e
BL
376#define DCA_MARKER_14B_BE 0x1FFFE800
377#define DCA_MARKER_14B_LE 0xFF1F00E8
378#define DCA_MARKER_RAW_BE 0x7FFE8001
379#define DCA_MARKER_RAW_LE 0xFE7F0180
380static int dts_probe(AVProbeData *p)
381{
382 const uint8_t *buf, *bufp;
383 uint32_t state = -1;
384
385 buf = p->buf;
386
387 for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
388 bufp = buf;
389 state = (state << 16) | bytestream_get_be16(&bufp);
390
391 /* Regular bitstream */
392 if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
393 return AVPROBE_SCORE_MAX/2+1;
394
395 /* 14 bits big endian bitstream */
396 if (state == DCA_MARKER_14B_BE)
397 if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
398 return AVPROBE_SCORE_MAX/2+1;
399
400 /* 14 bits little endian bitstream */
401 if (state == DCA_MARKER_14B_LE)
402 if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
403 return AVPROBE_SCORE_MAX/2+1;
404 }
405
406 return 0;
407}
408
17ac9f1c
LB
409static int dirac_probe(AVProbeData *p)
410{
411 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
412 return AVPROBE_SCORE_MAX;
413 else
414 return 0;
415}
416
7156aeb9
JR
417static int ac3_probe(AVProbeData *p)
418{
8c222bb4 419 int max_frames, first_frames = 0, frames;
f8b9830b
JR
420 uint8_t *buf, *buf2, *end;
421 AC3HeaderInfo hdr;
55736cfb 422 GetBitContext gbc;
7156aeb9 423
f8b9830b
JR
424 max_frames = 0;
425 buf = p->buf;
ecc8fc11 426 end = buf + p->buf_size;
f8b9830b
JR
427
428 for(; buf < end; buf++) {
429 buf2 = buf;
7156aeb9 430
f8b9830b 431 for(frames = 0; buf2 < end; frames++) {
55736cfb
BW
432 init_get_bits(&gbc, buf2, 54);
433 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
f8b9830b 434 break;
c675ef70
435 if(buf2 + hdr.frame_size > end ||
436 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
437 break;
f8b9830b
JR
438 buf2 += hdr.frame_size;
439 }
440 max_frames = FFMAX(max_frames, frames);
441 if(buf == p->buf)
442 first_frames = frames;
443 }
444 if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
2477ce23 445 else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
f8b9830b
JR
446 else if(max_frames>=1) return 1;
447 else return 0;
7156aeb9
JR
448}
449
e020dbd2
MN
450static int flac_probe(AVProbeData *p)
451{
452 if(memcmp(p->buf, "fLaC", 4)) return 0;
fbd69f51 453 else return AVPROBE_SCORE_MAX / 2;
e020dbd2
MN
454}
455
900eb63d
DB
456
457/* Note: Do not forget to add new entries to the Makefile as well. */
458
76d32428
DB
459AVInputFormat aac_demuxer = {
460 "aac",
461 NULL_IF_CONFIG_SMALL("ADTS AAC"),
16e861e3
RP
462 0,
463 NULL,
464 audio_read_header,
465 raw_read_partial_packet,
16e861e3 466 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
467 .extensions = "aac",
468 .value = CODEC_ID_AAC,
ce1d2a95 469};
ce1d2a95 470
cefd4907 471#ifdef CONFIG_AC3_DEMUXER
d2a067d1 472AVInputFormat ac3_demuxer = {
c9a65ca8 473 "ac3",
bde15e74 474 NULL_IF_CONFIG_SMALL("raw AC-3"),
c9a65ca8 475 0,
7156aeb9 476 ac3_probe,
a0af2fa4 477 audio_read_header,
e15dec10 478 raw_read_partial_packet,
e9b78eeb 479 .flags= AVFMT_GENERIC_INDEX,
bb76a117 480 .extensions = "ac3",
a0af2fa4 481 .value = CODEC_ID_AC3,
de6d9b64 482};
cefd4907 483#endif
de6d9b64 484
a9e35095 485#ifdef CONFIG_MUXERS
d2a067d1 486AVOutputFormat ac3_muxer = {
de6d9b64 487 "ac3",
bde15e74 488 NULL_IF_CONFIG_SMALL("raw AC-3"),
115329f1 489 "audio/x-ac3",
de6d9b64 490 "ac3",
c9a65ca8 491 0,
de6d9b64 492 CODEC_ID_AC3,
d9133126 493 CODEC_ID_NONE,
7a97dd84 494 NULL,
de6d9b64 495 raw_write_packet,
494bbf58 496 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 497};
a9e35095 498#endif //CONFIG_MUXERS
de6d9b64 499
17ac9f1c
LB
500AVInputFormat dirac_demuxer = {
501 "dirac",
bde15e74 502 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
503 0,
504 dirac_probe,
505 video_read_header,
506 raw_read_partial_packet,
17ac9f1c
LB
507 .flags= AVFMT_GENERIC_INDEX,
508 .value = CODEC_ID_DIRAC,
509};
510
511#ifdef CONFIG_MUXERS
512AVOutputFormat dirac_muxer = {
513 "dirac",
bde15e74 514 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
515 NULL,
516 "drc",
517 0,
d9133126 518 CODEC_ID_NONE,
17ac9f1c
LB
519 CODEC_ID_DIRAC,
520 NULL,
521 raw_write_packet,
522 .flags= AVFMT_NOTIMESTAMPS,
523};
524#endif
525
d2a067d1 526AVInputFormat dts_demuxer = {
23c99253 527 "dts",
bde15e74 528 NULL_IF_CONFIG_SMALL("raw DTS"),
23c99253 529 0,
fde8052e 530 dts_probe,
a0af2fa4 531 audio_read_header,
23c99253 532 raw_read_partial_packet,
e9b78eeb 533 .flags= AVFMT_GENERIC_INDEX,
23c99253 534 .extensions = "dts",
a0af2fa4 535 .value = CODEC_ID_DTS,
23c99253
MN
536};
537
76d32428
DB
538#ifdef CONFIG_MUXERS
539AVOutputFormat dts_muxer = {
540 "dts",
541 NULL_IF_CONFIG_SMALL("raw DTS"),
542 "audio/x-dca",
543 "dts",
fda885c7 544 0,
76d32428
DB
545 CODEC_ID_DTS,
546 CODEC_ID_NONE,
fda885c7 547 NULL,
76d32428
DB
548 raw_write_packet,
549 .flags= AVFMT_NOTIMESTAMPS,
550};
551#endif
552
553AVInputFormat flac_demuxer = {
554 "flac",
555 NULL_IF_CONFIG_SMALL("raw FLAC"),
556 0,
557 flac_probe,
a0af2fa4 558 audio_read_header,
fda885c7 559 raw_read_partial_packet,
e9b78eeb 560 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
561 .extensions = "flac",
562 .value = CODEC_ID_FLAC,
563};
564
565#ifdef CONFIG_MUXERS
566AVOutputFormat flac_muxer = {
567 "flac",
568 NULL_IF_CONFIG_SMALL("raw FLAC"),
569 "audio/x-flac",
570 "flac",
571 0,
572 CODEC_ID_FLAC,
573 CODEC_ID_NONE,
574 flac_write_header,
575 raw_write_packet,
576 .flags= AVFMT_NOTIMESTAMPS,
fda885c7 577};
76d32428 578#endif //CONFIG_MUXERS
fda885c7 579
60711e95
MN
580AVInputFormat gsm_demuxer = {
581 "gsm",
bde15e74 582 NULL_IF_CONFIG_SMALL("GSM"),
60711e95
MN
583 0,
584 NULL,
585 audio_read_header,
586 raw_read_partial_packet,
60711e95
MN
587 .flags= AVFMT_GENERIC_INDEX,
588 .extensions = "gsm",
589 .value = CODEC_ID_GSM,
590};
591
d2a067d1 592AVInputFormat h261_demuxer = {
c6148de2 593 "h261",
bde15e74 594 NULL_IF_CONFIG_SMALL("raw H.261"),
c6148de2
MN
595 0,
596 h261_probe,
597 video_read_header,
598 raw_read_partial_packet,
e9b78eeb 599 .flags= AVFMT_GENERIC_INDEX,
c6148de2
MN
600 .extensions = "h261",
601 .value = CODEC_ID_H261,
602};
603
a9e35095 604#ifdef CONFIG_MUXERS
d2a067d1 605AVOutputFormat h261_muxer = {
1c3990db 606 "h261",
bde15e74 607 NULL_IF_CONFIG_SMALL("raw H.261"),
1c3990db
MN
608 "video/x-h261",
609 "h261",
610 0,
d9133126 611 CODEC_ID_NONE,
1c3990db 612 CODEC_ID_H261,
7a97dd84 613 NULL,
1c3990db 614 raw_write_packet,
494bbf58 615 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 616};
a9e35095 617#endif //CONFIG_MUXERS
1c3990db 618
d2a067d1 619AVInputFormat h263_demuxer = {
d07f9043 620 "h263",
bde15e74 621 NULL_IF_CONFIG_SMALL("raw H.263"),
d07f9043
MN
622 0,
623 h263_probe,
624 video_read_header,
e15dec10 625 raw_read_partial_packet,
e9b78eeb 626 .flags= AVFMT_GENERIC_INDEX,
d07f9043
MN
627// .extensions = "h263", //FIXME remove after writing mpeg4_probe
628 .value = CODEC_ID_H263,
629};
630
a9e35095 631#ifdef CONFIG_MUXERS
d2a067d1 632AVOutputFormat h263_muxer = {
de6d9b64 633 "h263",
bde15e74 634 NULL_IF_CONFIG_SMALL("raw H.263"),
de6d9b64
FB
635 "video/x-h263",
636 "h263",
637 0,
d9133126 638 CODEC_ID_NONE,
de6d9b64 639 CODEC_ID_H263,
7a97dd84 640 NULL,
de6d9b64 641 raw_write_packet,
494bbf58 642 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 643};
a9e35095 644#endif //CONFIG_MUXERS
c9a65ca8 645
76d32428
DB
646AVInputFormat h264_demuxer = {
647 "h264",
648 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
649 0,
650 NULL /*mpegvideo_probe*/,
651 video_read_header,
652 raw_read_partial_packet,
653 .flags= AVFMT_GENERIC_INDEX,
654 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
655 .value = CODEC_ID_H264,
656};
657
658#ifdef CONFIG_MUXERS
659AVOutputFormat h264_muxer = {
660 "h264",
661 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
662 NULL,
663 "h264",
664 0,
665 CODEC_ID_NONE,
666 CODEC_ID_H264,
667 NULL,
668 raw_write_packet,
669 .flags= AVFMT_NOTIMESTAMPS,
670};
671#endif //CONFIG_MUXERS
672
673AVInputFormat ingenient_demuxer = {
674 "ingenient",
675 NULL_IF_CONFIG_SMALL("Ingenient MJPEG"),
676 0,
677 NULL,
678 video_read_header,
679 ingenient_read_packet,
680 .flags= AVFMT_GENERIC_INDEX,
681 .extensions = "cgi", // FIXME
682 .value = CODEC_ID_MJPEG,
683};
684
d2a067d1 685AVInputFormat m4v_demuxer = {
7866eeff 686 "m4v",
bde15e74 687 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
7866eeff 688 0,
8f57cc5a 689 mpeg4video_probe, /** probing for mpeg4 data */
7866eeff 690 video_read_header,
e15dec10 691 raw_read_partial_packet,
e9b78eeb 692 .flags= AVFMT_GENERIC_INDEX,
bb76a117
MR
693 .extensions = "m4v", //FIXME remove after writing mpeg4_probe
694 .value = CODEC_ID_MPEG4,
7866eeff
MN
695};
696
a9e35095 697#ifdef CONFIG_MUXERS
d2a067d1 698AVOutputFormat m4v_muxer = {
89b3d7c9 699 "m4v",
bde15e74 700 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
89b3d7c9
MK
701 NULL,
702 "m4v",
703 0,
704 CODEC_ID_NONE,
705 CODEC_ID_MPEG4,
7a97dd84 706 NULL,
89b3d7c9 707 raw_write_packet,
494bbf58 708 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 709};
a9e35095 710#endif //CONFIG_MUXERS
89b3d7c9 711
76d32428
DB
712AVInputFormat mjpeg_demuxer = {
713 "mjpeg",
714 NULL_IF_CONFIG_SMALL("MJPEG video"),
0da71265 715 0,
76d32428 716 NULL,
0da71265 717 video_read_header,
e15dec10 718 raw_read_partial_packet,
e9b78eeb 719 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
720 .extensions = "mjpg,mjpeg",
721 .value = CODEC_ID_MJPEG,
0da71265
MN
722};
723
a9e35095 724#ifdef CONFIG_MUXERS
76d32428
DB
725AVOutputFormat mjpeg_muxer = {
726 "mjpeg",
727 NULL_IF_CONFIG_SMALL("MJPEG video"),
728 "video/x-mjpeg",
729 "mjpg,mjpeg",
0da71265
MN
730 0,
731 CODEC_ID_NONE,
76d32428 732 CODEC_ID_MJPEG,
7a97dd84 733 NULL,
0da71265 734 raw_write_packet,
494bbf58 735 .flags= AVFMT_NOTIMESTAMPS,
0da71265 736};
a9e35095 737#endif //CONFIG_MUXERS
0da71265 738
76d32428
DB
739AVInputFormat mlp_demuxer = {
740 "mlp",
741 NULL_IF_CONFIG_SMALL("raw MLP"),
c9a65ca8 742 0,
76d32428
DB
743 NULL,
744 audio_read_header,
e15dec10 745 raw_read_partial_packet,
e9b78eeb 746 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
747 .extensions = "mlp",
748 .value = CODEC_ID_MLP,
de6d9b64
FB
749};
750
a9e35095 751#ifdef CONFIG_MUXERS
d2a067d1 752AVOutputFormat mpeg1video_muxer = {
c9a65ca8 753 "mpeg1video",
bde15e74 754 NULL_IF_CONFIG_SMALL("MPEG video"),
de6d9b64 755 "video/x-mpeg",
e0827ba4 756 "mpg,mpeg,m1v",
de6d9b64 757 0,
d9133126 758 CODEC_ID_NONE,
de6d9b64 759 CODEC_ID_MPEG1VIDEO,
7a97dd84 760 NULL,
de6d9b64 761 raw_write_packet,
494bbf58 762 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 763};
a9e35095 764#endif //CONFIG_MUXERS
de6d9b64 765
a9e35095 766#ifdef CONFIG_MUXERS
d2a067d1 767AVOutputFormat mpeg2video_muxer = {
6ec864da 768 "mpeg2video",
bde15e74 769 NULL_IF_CONFIG_SMALL("MPEG-2 video"),
6ec864da
MN
770 NULL,
771 "m2v",
772 0,
d9133126 773 CODEC_ID_NONE,
6ec864da 774 CODEC_ID_MPEG2VIDEO,
7a97dd84 775 NULL,
6ec864da 776 raw_write_packet,
494bbf58 777 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 778};
a9e35095 779#endif //CONFIG_MUXERS
6ec864da 780
76d32428
DB
781AVInputFormat mpegvideo_demuxer = {
782 "mpegvideo",
783 NULL_IF_CONFIG_SMALL("MPEG video"),
27e084bd 784 0,
76d32428 785 mpegvideo_probe,
27e084bd 786 video_read_header,
e15dec10 787 raw_read_partial_packet,
e9b78eeb 788 .flags= AVFMT_GENERIC_INDEX,
76d32428 789 .value = CODEC_ID_MPEG1VIDEO,
27e084bd
FB
790};
791
76d32428
DB
792#ifdef CONFIG_MUXERS
793AVOutputFormat null_muxer = {
794 "null",
795 NULL_IF_CONFIG_SMALL("null video format"),
796 NULL,
797 NULL,
84c63c01 798 0,
76d32428
DB
799#ifdef WORDS_BIGENDIAN
800 CODEC_ID_PCM_S16BE,
801#else
802 CODEC_ID_PCM_S16LE,
803#endif
804 CODEC_ID_RAWVIDEO,
84c63c01 805 NULL,
76d32428
DB
806 null_write_packet,
807 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
808};
809#endif //CONFIG_MUXERS
810
811AVInputFormat rawvideo_demuxer = {
812 "rawvideo",
813 NULL_IF_CONFIG_SMALL("raw video format"),
814 0,
815 NULL,
816 raw_read_header,
817 rawvideo_read_packet,
e9b78eeb 818 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
819 .extensions = "yuv,cif,qcif,rgb",
820 .value = CODEC_ID_RAWVIDEO,
84c63c01
AB
821};
822
a9e35095 823#ifdef CONFIG_MUXERS
76d32428
DB
824AVOutputFormat rawvideo_muxer = {
825 "rawvideo",
826 NULL_IF_CONFIG_SMALL("raw video format"),
827 NULL,
828 "yuv,rgb",
5ed8fafc 829 0,
d9133126 830 CODEC_ID_NONE,
76d32428 831 CODEC_ID_RAWVIDEO,
7a97dd84 832 NULL,
5ed8fafc 833 raw_write_packet,
494bbf58 834 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 835};
a9e35095 836#endif //CONFIG_MUXERS
5ed8fafc 837
76d32428
DB
838#ifdef CONFIG_ROQ_MUXER
839AVOutputFormat roq_muxer =
840{
841 "RoQ",
842 NULL_IF_CONFIG_SMALL("id RoQ format"),
843 NULL,
844 "roq",
845 0,
846 CODEC_ID_ROQ_DPCM,
847 CODEC_ID_ROQ,
848 roq_write_header,
849 raw_write_packet,
850};
851#endif //CONFIG_ROQ_MUXER
852
853AVInputFormat shorten_demuxer = {
854 "shn",
855 NULL_IF_CONFIG_SMALL("raw Shorten"),
856 0,
857 NULL,
858 audio_read_header,
859 raw_read_partial_packet,
860 .flags= AVFMT_GENERIC_INDEX,
861 .extensions = "shn",
862 .value = CODEC_ID_SHORTEN,
863};
864
7bb5c2a6
KS
865AVInputFormat vc1_demuxer = {
866 "vc1",
bde15e74 867 NULL_IF_CONFIG_SMALL("raw VC-1"),
7bb5c2a6
KS
868 0,
869 NULL /* vc1_probe */,
870 video_read_header,
871 raw_read_partial_packet,
7bb5c2a6
KS
872 .extensions = "vc1",
873 .value = CODEC_ID_VC1,
874};
875
c9a65ca8 876/* pcm formats */
764ef400 877
4986a429 878#define PCMINPUTDEF(name, long_name, ext, codec) \
d2a067d1 879AVInputFormat pcm_ ## name ## _demuxer = {\
764ef400 880 #name,\
bde15e74 881 NULL_IF_CONFIG_SMALL(long_name),\
764ef400
MM
882 0,\
883 NULL,\
884 raw_read_header,\
885 raw_read_packet,\
9b64a036 886 NULL,\
4986a429 887 pcm_read_seek,\
e9b78eeb 888 .flags= AVFMT_GENERIC_INDEX,\
764ef400
MM
889 .extensions = ext,\
890 .value = codec,\
891};
892
2c8e2014 893#define PCMOUTPUTDEF(name, long_name, ext, codec) \
d2a067d1 894AVOutputFormat pcm_ ## name ## _muxer = {\
c9a65ca8 895 #name,\
bde15e74 896 NULL_IF_CONFIG_SMALL(long_name),\
c9a65ca8
FB
897 NULL,\
898 ext,\
899 0,\
900 codec,\
d9133126 901 CODEC_ID_NONE,\
7a97dd84 902 NULL,\
c9a65ca8 903 raw_write_packet,\
494bbf58 904 .flags= AVFMT_NOTIMESTAMPS,\
5ed8fafc 905};
2c8e2014
DB
906
907
908#if !defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
909#define PCMDEF(name, long_name, ext, codec) \
910 PCMINPUTDEF(name, long_name, ext, codec)
911#elif defined(CONFIG_MUXERS) && !defined(CONFIG_DEMUXERS)
912#define PCMDEF(name, long_name, ext, codec) \
913 PCMOUTPUTDEF(name, long_name, ext, codec)
914#elif defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
915#define PCMDEF(name, long_name, ext, codec) \
916 PCMINPUTDEF(name, long_name, ext, codec)\
917 PCMOUTPUTDEF(name, long_name, ext, codec)
918#else
919#define PCMDEF(name, long_name, ext, codec)
920#endif
5ed8fafc 921
5ed8fafc 922#ifdef WORDS_BIGENDIAN
c9a65ca8
FB
923#define BE_DEF(s) s
924#define LE_DEF(s) NULL
5ed8fafc 925#else
c9a65ca8
FB
926#define BE_DEF(s) NULL
927#define LE_DEF(s) s
5ed8fafc 928#endif
5ed8fafc 929
5ed8fafc 930
ac1ea66e 931PCMDEF(s16be, "PCM signed 16 bit big-endian format",
c9a65ca8 932 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 933
76d32428
DB
934PCMDEF(s16le, "PCM signed 16 bit little-endian format",
935 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
936
937PCMDEF(s8, "PCM signed 8 bit format",
938 "sb", CODEC_ID_PCM_S8)
5ed8fafc 939
ac1ea66e 940PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
c9a65ca8 941 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 942
76d32428
DB
943PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
944 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 945
ac1ea66e 946PCMDEF(u8, "PCM unsigned 8 bit format",
c9a65ca8 947 "ub", CODEC_ID_PCM_U8)
5ed8fafc 948
ac1ea66e 949PCMDEF(alaw, "PCM A-law format",
c9a65ca8 950 "al", CODEC_ID_PCM_ALAW)
de6d9b64 951
76d32428
DB
952PCMDEF(mulaw, "PCM mu-law format",
953 "ul", CODEC_ID_PCM_MULAW)