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