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