cosmetics: misc spelling fixes
[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);
fb9f1117 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;
d701934b 224 int block_align, byte_rate, ret;
4986a429
FB
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);
d701934b
BC
246 if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
247 return ret;
4986a429
FB
248 return 0;
249}
250
a0af2fa4
BC
251static int audio_read_header(AVFormatContext *s,
252 AVFormatParameters *ap)
fda885c7 253{
a0af2fa4 254 AVStream *st = av_new_stream(s, 0);
fda885c7 255 if (!st)
769e10f0 256 return AVERROR(ENOMEM);
fda885c7 257 st->codec->codec_type = CODEC_TYPE_AUDIO;
a0af2fa4 258 st->codec->codec_id = s->iformat->value;
57004ff1 259 st->need_parsing = AVSTREAM_PARSE_FULL;
fda885c7
MR
260 /* the parameters will be extracted from the compressed bitstream */
261 return 0;
262}
263
fb9f1117 264/* MPEG-1/H.263 input */
de6d9b64
FB
265static int video_read_header(AVFormatContext *s,
266 AVFormatParameters *ap)
267{
268 AVStream *st;
269
c9a65ca8 270 st = av_new_stream(s, 0);
de6d9b64 271 if (!st)
769e10f0 272 return AVERROR(ENOMEM);
de6d9b64 273
01f4895c
MN
274 st->codec->codec_type = CODEC_TYPE_VIDEO;
275 st->codec->codec_id = s->iformat->value;
57004ff1 276 st->need_parsing = AVSTREAM_PARSE_FULL;
4986a429 277
fb9f1117
DB
278 /* for MJPEG, specify frame rate */
279 /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
c04c3282 280 if (ap->time_base.num) {
80ce3254 281 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
115329f1 282 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
01f4895c 283 st->codec->codec_id == CODEC_ID_MPEG4 ||
17ac9f1c 284 st->codec->codec_id == CODEC_ID_DIRAC ||
01f4895c 285 st->codec->codec_id == CODEC_ID_H264) {
80ce3254 286 av_set_pts_info(st, 64, 1, 25);
27e084bd 287 }
80ce3254 288
de6d9b64
FB
289 return 0;
290}
291
bb270c08
DB
292#define SEQ_START_CODE 0x000001b3
293#define GOP_START_CODE 0x000001b8
294#define PICTURE_START_CODE 0x00000100
93d3e278
MN
295#define SLICE_START_CODE 0x00000101
296#define PACK_START_CODE 0x000001ba
e01dc227
MR
297#define VIDEO_ID 0x000001e0
298#define AUDIO_ID 0x000001c0
c9a65ca8 299
c9a65ca8
FB
300static int mpegvideo_probe(AVProbeData *p)
301{
93d3e278 302 uint32_t code= -1;
e01dc227 303 int pic=0, seq=0, slice=0, pspack=0, pes=0;
93d3e278
MN
304 int i;
305
306 for(i=0; i<p->buf_size; i++){
307 code = (code<<8) + p->buf[i];
308 if ((code & 0xffffff00) == 0x100) {
309 switch(code){
310 case SEQ_START_CODE: seq++; break;
311 case PICTURE_START_CODE: pic++; break;
312 case SLICE_START_CODE: slice++; break;
313 case PACK_START_CODE: pspack++; break;
314 }
e9f6c8ea
MN
315 if ((code & 0x1f0) == VIDEO_ID) pes++;
316 else if((code & 0x1e0) == AUDIO_ID) pes++;
93d3e278 317 }
c9a65ca8 318 }
e01dc227 319 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
93d3e278 320 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
c9a65ca8
FB
321 return 0;
322}
323
8f57cc5a
TV
324#define VISUAL_OBJECT_START_CODE 0x000001b5
325#define VOP_START_CODE 0x000001b6
326
327static int mpeg4video_probe(AVProbeData *probe_packet)
328{
329 uint32_t temp_buffer= -1;
5fd5d0ef 330 int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
8f57cc5a
TV
331 int i;
332
333 for(i=0; i<probe_packet->buf_size; i++){
334 temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
c21f308e
RS
335 if ((temp_buffer & 0xffffff00) != 0x100)
336 continue;
337
338 if (temp_buffer == VOP_START_CODE) VOP++;
339 else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;
340 else if (temp_buffer < 0x120) VO++;
341 else if (temp_buffer < 0x130) VOL++;
342 else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
343 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
8f57cc5a
TV
344 }
345
5fd5d0ef 346 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
8f57cc5a
TV
347 return AVPROBE_SCORE_MAX/2;
348 return 0;
349}
350
010acd8e
MN
351static int h264_probe(AVProbeData *p)
352{
353 uint32_t code= -1;
01037451 354 int sps=0, pps=0, idr=0, res=0, sli=0;
010acd8e
MN
355 int i;
356
357 for(i=0; i<p->buf_size; i++){
358 code = (code<<8) + p->buf[i];
359 if ((code & 0xffffff00) == 0x100) {
360 int ref_idc= (code>>5)&3;
361 int type = code & 0x1F;
362 static const int8_t ref_zero[32]={
363 2, 0, 0, 0, 0,-1, 1,-1,
364 -1, 1, 1, 1, 1,-1, 2, 2,
365 2, 2, 2, 0, 2, 2, 2, 2,
366 2, 2, 2, 2, 2, 2, 2, 2
367 };
368
369 if(code & 0x80) //forbidden bit
370 return 0;
371
372 if(ref_zero[type] == 1 && ref_idc)
373 return 0;
374 if(ref_zero[type] ==-1 && !ref_idc)
375 return 0;
376 if(ref_zero[type] == 2)
377 res++;
378
379 switch(type){
01037451 380 case 1: sli++; break;
010acd8e
MN
381 case 5: idr++; break;
382 case 7:
383 if(p->buf[i+2]&0x0F)
384 return 0;
385 sps++;
386 break;
387 case 8: pps++; break;
388 }
389 }
390 }
01037451 391 if(sps && pps && (idr||sli>3) && res<(sps+pps+idr))
010acd8e
MN
392 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
393 return 0;
394}
395
d07f9043
MN
396static int h263_probe(AVProbeData *p)
397{
398 int code;
399 const uint8_t *d;
400
d07f9043
MN
401 d = p->buf;
402 code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
403 if (code == 0x20) {
404 return 50;
405 }
406 return 0;
407}
408
c6148de2
MN
409static int h261_probe(AVProbeData *p)
410{
411 int code;
412 const uint8_t *d;
413
c6148de2
MN
414 d = p->buf;
415 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
416 if (code == 0x10) {
417 return 50;
418 }
419 return 0;
420}
421
fde8052e
BL
422#define DCA_MARKER_14B_BE 0x1FFFE800
423#define DCA_MARKER_14B_LE 0xFF1F00E8
424#define DCA_MARKER_RAW_BE 0x7FFE8001
425#define DCA_MARKER_RAW_LE 0xFE7F0180
426static int dts_probe(AVProbeData *p)
427{
428 const uint8_t *buf, *bufp;
429 uint32_t state = -1;
430
431 buf = p->buf;
432
433 for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
434 bufp = buf;
435 state = (state << 16) | bytestream_get_be16(&bufp);
436
fb9f1117 437 /* regular bitstream */
fde8052e
BL
438 if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
439 return AVPROBE_SCORE_MAX/2+1;
440
fb9f1117 441 /* 14 bits big-endian bitstream */
fde8052e
BL
442 if (state == DCA_MARKER_14B_BE)
443 if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
444 return AVPROBE_SCORE_MAX/2+1;
445
fb9f1117 446 /* 14 bits little-endian bitstream */
fde8052e
BL
447 if (state == DCA_MARKER_14B_LE)
448 if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
449 return AVPROBE_SCORE_MAX/2+1;
450 }
451
452 return 0;
453}
454
17ac9f1c
LB
455static int dirac_probe(AVProbeData *p)
456{
457 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
458 return AVPROBE_SCORE_MAX;
459 else
460 return 0;
461}
462
7156aeb9
JR
463static int ac3_probe(AVProbeData *p)
464{
8c222bb4 465 int max_frames, first_frames = 0, frames;
f8b9830b
JR
466 uint8_t *buf, *buf2, *end;
467 AC3HeaderInfo hdr;
55736cfb 468 GetBitContext gbc;
7156aeb9 469
f8b9830b
JR
470 max_frames = 0;
471 buf = p->buf;
ecc8fc11 472 end = buf + p->buf_size;
f8b9830b
JR
473
474 for(; buf < end; buf++) {
475 buf2 = buf;
7156aeb9 476
f8b9830b 477 for(frames = 0; buf2 < end; frames++) {
55736cfb
BW
478 init_get_bits(&gbc, buf2, 54);
479 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
f8b9830b 480 break;
c675ef70
481 if(buf2 + hdr.frame_size > end ||
482 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
483 break;
f8b9830b
JR
484 buf2 += hdr.frame_size;
485 }
486 max_frames = FFMAX(max_frames, frames);
487 if(buf == p->buf)
488 first_frames = frames;
489 }
490 if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
2477ce23 491 else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
f8b9830b
JR
492 else if(max_frames>=1) return 1;
493 else return 0;
7156aeb9
JR
494}
495
e020dbd2
MN
496static int flac_probe(AVProbeData *p)
497{
498 if(memcmp(p->buf, "fLaC", 4)) return 0;
fbd69f51 499 else return AVPROBE_SCORE_MAX / 2;
e020dbd2
MN
500}
501
900eb63d
DB
502
503/* Note: Do not forget to add new entries to the Makefile as well. */
504
76d32428
DB
505AVInputFormat aac_demuxer = {
506 "aac",
507 NULL_IF_CONFIG_SMALL("ADTS AAC"),
16e861e3
RP
508 0,
509 NULL,
510 audio_read_header,
511 raw_read_partial_packet,
16e861e3 512 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
513 .extensions = "aac",
514 .value = CODEC_ID_AAC,
ce1d2a95 515};
ce1d2a95 516
cefd4907 517#ifdef CONFIG_AC3_DEMUXER
d2a067d1 518AVInputFormat ac3_demuxer = {
c9a65ca8 519 "ac3",
bde15e74 520 NULL_IF_CONFIG_SMALL("raw AC-3"),
c9a65ca8 521 0,
7156aeb9 522 ac3_probe,
a0af2fa4 523 audio_read_header,
e15dec10 524 raw_read_partial_packet,
e9b78eeb 525 .flags= AVFMT_GENERIC_INDEX,
bb76a117 526 .extensions = "ac3",
a0af2fa4 527 .value = CODEC_ID_AC3,
de6d9b64 528};
cefd4907 529#endif
de6d9b64 530
a9e35095 531#ifdef CONFIG_MUXERS
d2a067d1 532AVOutputFormat ac3_muxer = {
de6d9b64 533 "ac3",
bde15e74 534 NULL_IF_CONFIG_SMALL("raw AC-3"),
115329f1 535 "audio/x-ac3",
de6d9b64 536 "ac3",
c9a65ca8 537 0,
de6d9b64 538 CODEC_ID_AC3,
d9133126 539 CODEC_ID_NONE,
7a97dd84 540 NULL,
de6d9b64 541 raw_write_packet,
494bbf58 542 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 543};
a9e35095 544#endif //CONFIG_MUXERS
de6d9b64 545
17ac9f1c
LB
546AVInputFormat dirac_demuxer = {
547 "dirac",
bde15e74 548 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
549 0,
550 dirac_probe,
551 video_read_header,
552 raw_read_partial_packet,
17ac9f1c
LB
553 .flags= AVFMT_GENERIC_INDEX,
554 .value = CODEC_ID_DIRAC,
555};
556
557#ifdef CONFIG_MUXERS
558AVOutputFormat dirac_muxer = {
559 "dirac",
bde15e74 560 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
561 NULL,
562 "drc",
563 0,
d9133126 564 CODEC_ID_NONE,
17ac9f1c
LB
565 CODEC_ID_DIRAC,
566 NULL,
567 raw_write_packet,
568 .flags= AVFMT_NOTIMESTAMPS,
569};
570#endif
571
d2a067d1 572AVInputFormat dts_demuxer = {
23c99253 573 "dts",
bde15e74 574 NULL_IF_CONFIG_SMALL("raw DTS"),
23c99253 575 0,
fde8052e 576 dts_probe,
a0af2fa4 577 audio_read_header,
23c99253 578 raw_read_partial_packet,
e9b78eeb 579 .flags= AVFMT_GENERIC_INDEX,
23c99253 580 .extensions = "dts",
a0af2fa4 581 .value = CODEC_ID_DTS,
23c99253
MN
582};
583
76d32428
DB
584#ifdef CONFIG_MUXERS
585AVOutputFormat dts_muxer = {
586 "dts",
587 NULL_IF_CONFIG_SMALL("raw DTS"),
588 "audio/x-dca",
589 "dts",
fda885c7 590 0,
76d32428
DB
591 CODEC_ID_DTS,
592 CODEC_ID_NONE,
fda885c7 593 NULL,
76d32428
DB
594 raw_write_packet,
595 .flags= AVFMT_NOTIMESTAMPS,
596};
597#endif
598
599AVInputFormat flac_demuxer = {
600 "flac",
601 NULL_IF_CONFIG_SMALL("raw FLAC"),
602 0,
603 flac_probe,
a0af2fa4 604 audio_read_header,
fda885c7 605 raw_read_partial_packet,
e9b78eeb 606 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
607 .extensions = "flac",
608 .value = CODEC_ID_FLAC,
609};
610
611#ifdef CONFIG_MUXERS
612AVOutputFormat flac_muxer = {
613 "flac",
614 NULL_IF_CONFIG_SMALL("raw FLAC"),
615 "audio/x-flac",
616 "flac",
617 0,
618 CODEC_ID_FLAC,
619 CODEC_ID_NONE,
620 flac_write_header,
621 raw_write_packet,
622 .flags= AVFMT_NOTIMESTAMPS,
fda885c7 623};
76d32428 624#endif //CONFIG_MUXERS
fda885c7 625
60711e95
MN
626AVInputFormat gsm_demuxer = {
627 "gsm",
bde15e74 628 NULL_IF_CONFIG_SMALL("GSM"),
60711e95
MN
629 0,
630 NULL,
631 audio_read_header,
632 raw_read_partial_packet,
60711e95
MN
633 .flags= AVFMT_GENERIC_INDEX,
634 .extensions = "gsm",
635 .value = CODEC_ID_GSM,
636};
637
d2a067d1 638AVInputFormat h261_demuxer = {
c6148de2 639 "h261",
bde15e74 640 NULL_IF_CONFIG_SMALL("raw H.261"),
c6148de2
MN
641 0,
642 h261_probe,
643 video_read_header,
644 raw_read_partial_packet,
e9b78eeb 645 .flags= AVFMT_GENERIC_INDEX,
c6148de2
MN
646 .extensions = "h261",
647 .value = CODEC_ID_H261,
648};
649
a9e35095 650#ifdef CONFIG_MUXERS
d2a067d1 651AVOutputFormat h261_muxer = {
1c3990db 652 "h261",
bde15e74 653 NULL_IF_CONFIG_SMALL("raw H.261"),
1c3990db
MN
654 "video/x-h261",
655 "h261",
656 0,
d9133126 657 CODEC_ID_NONE,
1c3990db 658 CODEC_ID_H261,
7a97dd84 659 NULL,
1c3990db 660 raw_write_packet,
494bbf58 661 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 662};
a9e35095 663#endif //CONFIG_MUXERS
1c3990db 664
d2a067d1 665AVInputFormat h263_demuxer = {
d07f9043 666 "h263",
bde15e74 667 NULL_IF_CONFIG_SMALL("raw H.263"),
d07f9043
MN
668 0,
669 h263_probe,
670 video_read_header,
e15dec10 671 raw_read_partial_packet,
e9b78eeb 672 .flags= AVFMT_GENERIC_INDEX,
d07f9043
MN
673// .extensions = "h263", //FIXME remove after writing mpeg4_probe
674 .value = CODEC_ID_H263,
675};
676
a9e35095 677#ifdef CONFIG_MUXERS
d2a067d1 678AVOutputFormat h263_muxer = {
de6d9b64 679 "h263",
bde15e74 680 NULL_IF_CONFIG_SMALL("raw H.263"),
de6d9b64
FB
681 "video/x-h263",
682 "h263",
683 0,
d9133126 684 CODEC_ID_NONE,
de6d9b64 685 CODEC_ID_H263,
7a97dd84 686 NULL,
de6d9b64 687 raw_write_packet,
494bbf58 688 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 689};
a9e35095 690#endif //CONFIG_MUXERS
c9a65ca8 691
76d32428
DB
692AVInputFormat h264_demuxer = {
693 "h264",
694 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
695 0,
010acd8e 696 h264_probe,
76d32428
DB
697 video_read_header,
698 raw_read_partial_packet,
699 .flags= AVFMT_GENERIC_INDEX,
700 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
701 .value = CODEC_ID_H264,
702};
703
704#ifdef CONFIG_MUXERS
705AVOutputFormat h264_muxer = {
706 "h264",
707 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
708 NULL,
709 "h264",
710 0,
711 CODEC_ID_NONE,
712 CODEC_ID_H264,
713 NULL,
714 raw_write_packet,
715 .flags= AVFMT_NOTIMESTAMPS,
716};
717#endif //CONFIG_MUXERS
718
719AVInputFormat ingenient_demuxer = {
720 "ingenient",
721 NULL_IF_CONFIG_SMALL("Ingenient MJPEG"),
722 0,
723 NULL,
724 video_read_header,
725 ingenient_read_packet,
726 .flags= AVFMT_GENERIC_INDEX,
727 .extensions = "cgi", // FIXME
728 .value = CODEC_ID_MJPEG,
729};
730
d2a067d1 731AVInputFormat m4v_demuxer = {
7866eeff 732 "m4v",
bde15e74 733 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
7866eeff 734 0,
fb9f1117 735 mpeg4video_probe, /** probing for MPEG-4 data */
7866eeff 736 video_read_header,
e15dec10 737 raw_read_partial_packet,
e9b78eeb 738 .flags= AVFMT_GENERIC_INDEX,
bb76a117
MR
739 .extensions = "m4v", //FIXME remove after writing mpeg4_probe
740 .value = CODEC_ID_MPEG4,
7866eeff
MN
741};
742
a9e35095 743#ifdef CONFIG_MUXERS
d2a067d1 744AVOutputFormat m4v_muxer = {
89b3d7c9 745 "m4v",
bde15e74 746 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
89b3d7c9
MK
747 NULL,
748 "m4v",
749 0,
750 CODEC_ID_NONE,
751 CODEC_ID_MPEG4,
7a97dd84 752 NULL,
89b3d7c9 753 raw_write_packet,
494bbf58 754 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 755};
a9e35095 756#endif //CONFIG_MUXERS
89b3d7c9 757
76d32428
DB
758AVInputFormat mjpeg_demuxer = {
759 "mjpeg",
760 NULL_IF_CONFIG_SMALL("MJPEG video"),
0da71265 761 0,
76d32428 762 NULL,
0da71265 763 video_read_header,
e15dec10 764 raw_read_partial_packet,
e9b78eeb 765 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
766 .extensions = "mjpg,mjpeg",
767 .value = CODEC_ID_MJPEG,
0da71265
MN
768};
769
a9e35095 770#ifdef CONFIG_MUXERS
76d32428
DB
771AVOutputFormat mjpeg_muxer = {
772 "mjpeg",
773 NULL_IF_CONFIG_SMALL("MJPEG video"),
774 "video/x-mjpeg",
775 "mjpg,mjpeg",
0da71265
MN
776 0,
777 CODEC_ID_NONE,
76d32428 778 CODEC_ID_MJPEG,
7a97dd84 779 NULL,
0da71265 780 raw_write_packet,
494bbf58 781 .flags= AVFMT_NOTIMESTAMPS,
0da71265 782};
a9e35095 783#endif //CONFIG_MUXERS
0da71265 784
76d32428
DB
785AVInputFormat mlp_demuxer = {
786 "mlp",
787 NULL_IF_CONFIG_SMALL("raw MLP"),
c9a65ca8 788 0,
76d32428
DB
789 NULL,
790 audio_read_header,
e15dec10 791 raw_read_partial_packet,
e9b78eeb 792 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
793 .extensions = "mlp",
794 .value = CODEC_ID_MLP,
de6d9b64
FB
795};
796
a9e35095 797#ifdef CONFIG_MUXERS
d2a067d1 798AVOutputFormat mpeg1video_muxer = {
c9a65ca8 799 "mpeg1video",
bde15e74 800 NULL_IF_CONFIG_SMALL("MPEG video"),
de6d9b64 801 "video/x-mpeg",
e0827ba4 802 "mpg,mpeg,m1v",
de6d9b64 803 0,
d9133126 804 CODEC_ID_NONE,
de6d9b64 805 CODEC_ID_MPEG1VIDEO,
7a97dd84 806 NULL,
de6d9b64 807 raw_write_packet,
494bbf58 808 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 809};
a9e35095 810#endif //CONFIG_MUXERS
de6d9b64 811
a9e35095 812#ifdef CONFIG_MUXERS
d2a067d1 813AVOutputFormat mpeg2video_muxer = {
6ec864da 814 "mpeg2video",
bde15e74 815 NULL_IF_CONFIG_SMALL("MPEG-2 video"),
6ec864da
MN
816 NULL,
817 "m2v",
818 0,
d9133126 819 CODEC_ID_NONE,
6ec864da 820 CODEC_ID_MPEG2VIDEO,
7a97dd84 821 NULL,
6ec864da 822 raw_write_packet,
494bbf58 823 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 824};
a9e35095 825#endif //CONFIG_MUXERS
6ec864da 826
76d32428
DB
827AVInputFormat mpegvideo_demuxer = {
828 "mpegvideo",
829 NULL_IF_CONFIG_SMALL("MPEG video"),
27e084bd 830 0,
76d32428 831 mpegvideo_probe,
27e084bd 832 video_read_header,
e15dec10 833 raw_read_partial_packet,
e9b78eeb 834 .flags= AVFMT_GENERIC_INDEX,
76d32428 835 .value = CODEC_ID_MPEG1VIDEO,
27e084bd
FB
836};
837
76d32428
DB
838#ifdef CONFIG_MUXERS
839AVOutputFormat null_muxer = {
840 "null",
841 NULL_IF_CONFIG_SMALL("null video format"),
842 NULL,
843 NULL,
84c63c01 844 0,
76d32428
DB
845#ifdef WORDS_BIGENDIAN
846 CODEC_ID_PCM_S16BE,
847#else
848 CODEC_ID_PCM_S16LE,
849#endif
850 CODEC_ID_RAWVIDEO,
84c63c01 851 NULL,
76d32428
DB
852 null_write_packet,
853 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
854};
855#endif //CONFIG_MUXERS
856
857AVInputFormat rawvideo_demuxer = {
858 "rawvideo",
859 NULL_IF_CONFIG_SMALL("raw video format"),
860 0,
861 NULL,
862 raw_read_header,
863 rawvideo_read_packet,
e9b78eeb 864 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
865 .extensions = "yuv,cif,qcif,rgb",
866 .value = CODEC_ID_RAWVIDEO,
84c63c01
AB
867};
868
a9e35095 869#ifdef CONFIG_MUXERS
76d32428
DB
870AVOutputFormat rawvideo_muxer = {
871 "rawvideo",
872 NULL_IF_CONFIG_SMALL("raw video format"),
873 NULL,
874 "yuv,rgb",
5ed8fafc 875 0,
d9133126 876 CODEC_ID_NONE,
76d32428 877 CODEC_ID_RAWVIDEO,
7a97dd84 878 NULL,
5ed8fafc 879 raw_write_packet,
494bbf58 880 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 881};
a9e35095 882#endif //CONFIG_MUXERS
5ed8fafc 883
76d32428
DB
884#ifdef CONFIG_ROQ_MUXER
885AVOutputFormat roq_muxer =
886{
887 "RoQ",
888 NULL_IF_CONFIG_SMALL("id RoQ format"),
889 NULL,
890 "roq",
891 0,
892 CODEC_ID_ROQ_DPCM,
893 CODEC_ID_ROQ,
894 roq_write_header,
895 raw_write_packet,
896};
897#endif //CONFIG_ROQ_MUXER
898
899AVInputFormat shorten_demuxer = {
900 "shn",
901 NULL_IF_CONFIG_SMALL("raw Shorten"),
902 0,
903 NULL,
904 audio_read_header,
905 raw_read_partial_packet,
906 .flags= AVFMT_GENERIC_INDEX,
907 .extensions = "shn",
908 .value = CODEC_ID_SHORTEN,
909};
910
7bb5c2a6
KS
911AVInputFormat vc1_demuxer = {
912 "vc1",
bde15e74 913 NULL_IF_CONFIG_SMALL("raw VC-1"),
7bb5c2a6
KS
914 0,
915 NULL /* vc1_probe */,
916 video_read_header,
917 raw_read_partial_packet,
7bb5c2a6
KS
918 .extensions = "vc1",
919 .value = CODEC_ID_VC1,
920};
921
fb9f1117 922/* PCM formats */
764ef400 923
4986a429 924#define PCMINPUTDEF(name, long_name, ext, codec) \
d2a067d1 925AVInputFormat pcm_ ## name ## _demuxer = {\
764ef400 926 #name,\
bde15e74 927 NULL_IF_CONFIG_SMALL(long_name),\
764ef400
MM
928 0,\
929 NULL,\
930 raw_read_header,\
931 raw_read_packet,\
9b64a036 932 NULL,\
4986a429 933 pcm_read_seek,\
e9b78eeb 934 .flags= AVFMT_GENERIC_INDEX,\
764ef400
MM
935 .extensions = ext,\
936 .value = codec,\
937};
938
2c8e2014 939#define PCMOUTPUTDEF(name, long_name, ext, codec) \
d2a067d1 940AVOutputFormat pcm_ ## name ## _muxer = {\
c9a65ca8 941 #name,\
bde15e74 942 NULL_IF_CONFIG_SMALL(long_name),\
c9a65ca8
FB
943 NULL,\
944 ext,\
945 0,\
946 codec,\
d9133126 947 CODEC_ID_NONE,\
7a97dd84 948 NULL,\
c9a65ca8 949 raw_write_packet,\
494bbf58 950 .flags= AVFMT_NOTIMESTAMPS,\
5ed8fafc 951};
2c8e2014
DB
952
953
954#if !defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
955#define PCMDEF(name, long_name, ext, codec) \
956 PCMINPUTDEF(name, long_name, ext, codec)
957#elif defined(CONFIG_MUXERS) && !defined(CONFIG_DEMUXERS)
958#define PCMDEF(name, long_name, ext, codec) \
959 PCMOUTPUTDEF(name, long_name, ext, codec)
960#elif defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
961#define PCMDEF(name, long_name, ext, codec) \
962 PCMINPUTDEF(name, long_name, ext, codec)\
963 PCMOUTPUTDEF(name, long_name, ext, codec)
964#else
965#define PCMDEF(name, long_name, ext, codec)
966#endif
5ed8fafc 967
5ed8fafc 968#ifdef WORDS_BIGENDIAN
c9a65ca8
FB
969#define BE_DEF(s) s
970#define LE_DEF(s) NULL
5ed8fafc 971#else
c9a65ca8
FB
972#define BE_DEF(s) NULL
973#define LE_DEF(s) s
5ed8fafc 974#endif
5ed8fafc 975
5ed8fafc 976
ac1ea66e 977PCMDEF(s16be, "PCM signed 16 bit big-endian format",
c9a65ca8 978 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 979
76d32428
DB
980PCMDEF(s16le, "PCM signed 16 bit little-endian format",
981 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
982
983PCMDEF(s8, "PCM signed 8 bit format",
984 "sb", CODEC_ID_PCM_S8)
5ed8fafc 985
ac1ea66e 986PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
c9a65ca8 987 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 988
76d32428
DB
989PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
990 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 991
ac1ea66e 992PCMDEF(u8, "PCM unsigned 8 bit format",
c9a65ca8 993 "ub", CODEC_ID_PCM_U8)
5ed8fafc 994
ac1ea66e 995PCMDEF(alaw, "PCM A-law format",
c9a65ca8 996 "al", CODEC_ID_PCM_ALAW)
de6d9b64 997
76d32428
DB
998PCMDEF(mulaw, "PCM mu-law format",
999 "ul", CODEC_ID_PCM_MULAW)