Simplify packet duplication code in ff_interleave_add_packet.
[libav.git] / libavformat / raw.c
CommitLineData
115329f1 1/*
7fbde343 2 * RAW muxer and demuxer
406792e7 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"
ac3ef4a4 29#include "id3v2.h"
de6d9b64
FB
30
31/* simple formats */
ce1d2a95 32
b250f9c6 33#if CONFIG_ROQ_MUXER
13dec857
VS
34static int roq_write_header(struct AVFormatContext *s)
35{
36 static const uint8_t header[] = {
37 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
38 };
39
899681cd
BA
40 put_buffer(s->pb, header, 8);
41 put_flush_packet(s->pb);
13dec857
VS
42
43 return 0;
44}
96445426 45#endif
13dec857 46
b250f9c6 47#if CONFIG_NULL_MUXER
76d32428
DB
48static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
49{
50 return 0;
51}
96445426 52#endif
76d32428 53
b250f9c6 54#if CONFIG_MUXERS
e928649b 55static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
de6d9b64 56{
899681cd
BA
57 put_buffer(s->pb, pkt->data, pkt->size);
58 put_flush_packet(s->pb);
de6d9b64
FB
59 return 0;
60}
082f7acf 61#endif
de6d9b64 62
b250f9c6 63#if CONFIG_DEMUXERS
de6d9b64 64/* raw input */
0c1a9eda 65static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
de6d9b64
FB
66{
67 AVStream *st;
c9a65ca8 68 int id;
de6d9b64 69
c9a65ca8 70 st = av_new_stream(s, 0);
de6d9b64 71 if (!st)
769e10f0 72 return AVERROR(ENOMEM);
c04c3282 73
c9a65ca8
FB
74 id = s->iformat->value;
75 if (id == CODEC_ID_RAWVIDEO) {
01f4895c 76 st->codec->codec_type = CODEC_TYPE_VIDEO;
de6d9b64 77 } else {
01f4895c 78 st->codec->codec_type = CODEC_TYPE_AUDIO;
de6d9b64 79 }
01f4895c 80 st->codec->codec_id = id;
c9a65ca8 81
01f4895c 82 switch(st->codec->codec_type) {
de6d9b64 83 case CODEC_TYPE_AUDIO:
01f4895c 84 st->codec->sample_rate = ap->sample_rate;
bf9067cf
MN
85 if(ap->channels) st->codec->channels = ap->channels;
86 else st->codec->channels = 1;
01f4895c 87 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
de6d9b64
FB
88 break;
89 case CODEC_TYPE_VIDEO:
9de0be61
MN
90 if(ap->time_base.num)
91 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
92 else
93 av_set_pts_info(st, 64, 1, 25);
01f4895c
MN
94 st->codec->width = ap->width;
95 st->codec->height = ap->height;
96 st->codec->pix_fmt = ap->pix_fmt;
97 if(st->codec->pix_fmt == PIX_FMT_NONE)
98 st->codec->pix_fmt= PIX_FMT_YUV420P;
de6d9b64
FB
99 break;
100 default:
27e084bd 101 return -1;
de6d9b64 102 }
de6d9b64
FB
103 return 0;
104}
105
2e93e3aa 106#define RAW_PACKET_SIZE 1024
de6d9b64 107
5c91a675 108static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 109{
f5b41031 110 int ret, size, bps;
2a6874fd 111 // AVStream *st = s->streams[0];
115329f1 112
231dd3f3 113 size= RAW_PACKET_SIZE;
de6d9b64 114
899681cd 115 ret= av_get_packet(s->pb, pkt, size);
de6d9b64
FB
116
117 pkt->stream_index = 0;
2e93e3aa 118 if (ret <= 0) {
6f3e0b21 119 return AVERROR(EIO);
2e93e3aa
FB
120 }
121 /* note: we need to modify the packet size here to handle the last
122 packet */
123 pkt->size = ret;
f5b41031
MN
124
125 bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
126 assert(bps); // if false there IS a bug elsewhere (NOT in this function)
127 pkt->dts=
128 pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
129
de6d9b64
FB
130 return ret;
131}
132
81f052cb 133int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
e15dec10
LS
134{
135 int ret, size;
136
137 size = RAW_PACKET_SIZE;
138
139 if (av_new_packet(pkt, size) < 0)
6f3e0b21 140 return AVERROR(EIO);
115329f1 141
899681cd 142 pkt->pos= url_ftell(s->pb);
e15dec10 143 pkt->stream_index = 0;
899681cd 144 ret = get_partial_buffer(s->pb, pkt->data, size);
e15dec10
LS
145 if (ret <= 0) {
146 av_free_packet(pkt);
6f3e0b21 147 return AVERROR(EIO);
e15dec10
LS
148 }
149 pkt->size = ret;
150 return ret;
151}
4c00864f 152#endif
e15dec10 153
b250f9c6 154#if CONFIG_RAWVIDEO_DEMUXER
76d32428
DB
155static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
156{
157 int packet_size, ret, width, height;
158 AVStream *st = s->streams[0];
159
160 width = st->codec->width;
161 height = st->codec->height;
162
163 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
164 if (packet_size < 0)
165 return -1;
166
167 ret= av_get_packet(s->pb, pkt, packet_size);
168 pkt->pts=
169 pkt->dts= pkt->pos / packet_size;
170
171 pkt->stream_index = 0;
172 if (ret != packet_size) {
173 return AVERROR(EIO);
174 } else {
175 return 0;
176 }
177}
4c00864f 178#endif
76d32428 179
b250f9c6 180#if CONFIG_INGENIENT_DEMUXER
84c63c01
AB
181// http://www.artificis.hu/files/texts/ingenient.txt
182static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
183{
184 int ret, size, w, h, unk1, unk2;
115329f1 185
899681cd 186 if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
6f3e0b21 187 return AVERROR(EIO); // FIXME
84c63c01 188
899681cd 189 size = get_le32(s->pb);
115329f1 190
899681cd
BA
191 w = get_le16(s->pb);
192 h = get_le16(s->pb);
115329f1 193
899681cd
BA
194 url_fskip(s->pb, 8); // zero + size (padded?)
195 url_fskip(s->pb, 2);
196 unk1 = get_le16(s->pb);
197 unk2 = get_le16(s->pb);
fb9f1117 198 url_fskip(s->pb, 22); // ASCII timestamp
115329f1 199
ff9843ca 200 av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
bb270c08 201 size, w, h, unk1, unk2);
84c63c01
AB
202
203 if (av_new_packet(pkt, size) < 0)
6f3e0b21 204 return AVERROR(EIO);
84c63c01 205
899681cd 206 pkt->pos = url_ftell(s->pb);
84c63c01 207 pkt->stream_index = 0;
899681cd 208 ret = get_buffer(s->pb, pkt->data, size);
84c63c01
AB
209 if (ret <= 0) {
210 av_free_packet(pkt);
6f3e0b21 211 return AVERROR(EIO);
84c63c01
AB
212 }
213 pkt->size = ret;
214 return ret;
215}
4c00864f 216#endif
84c63c01 217
b250f9c6 218#if CONFIG_DEMUXERS
115329f1 219int pcm_read_seek(AVFormatContext *s,
7b3c1382 220 int stream_index, int64_t timestamp, int flags)
4986a429
FB
221{
222 AVStream *st;
d701934b 223 int block_align, byte_rate, ret;
4986a429
FB
224 int64_t pos;
225
226 st = s->streams[0];
708e3e7d
BC
227
228 block_align = st->codec->block_align ? st->codec->block_align :
229 (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
230 byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
231 block_align * st->codec->sample_rate;
115329f1 232
4986a429
FB
233 if (block_align <= 0 || byte_rate <= 0)
234 return -1;
bd36f175 235 if (timestamp < 0) timestamp = 0;
4986a429
FB
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 260 /* the parameters will be extracted from the compressed bitstream */
6cde949a 261
fda885c7
MR
262 return 0;
263}
264
fb9f1117 265/* MPEG-1/H.263 input */
de6d9b64
FB
266static int video_read_header(AVFormatContext *s,
267 AVFormatParameters *ap)
268{
269 AVStream *st;
270
c9a65ca8 271 st = av_new_stream(s, 0);
de6d9b64 272 if (!st)
769e10f0 273 return AVERROR(ENOMEM);
de6d9b64 274
01f4895c
MN
275 st->codec->codec_type = CODEC_TYPE_VIDEO;
276 st->codec->codec_id = s->iformat->value;
57004ff1 277 st->need_parsing = AVSTREAM_PARSE_FULL;
4986a429 278
fb9f1117
DB
279 /* for MJPEG, specify frame rate */
280 /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
c04c3282 281 if (ap->time_base.num) {
4022fe01 282 st->codec->time_base= ap->time_base;
115329f1 283 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
01f4895c 284 st->codec->codec_id == CODEC_ID_MPEG4 ||
17ac9f1c 285 st->codec->codec_id == CODEC_ID_DIRAC ||
01f4895c 286 st->codec->codec_id == CODEC_ID_H264) {
4022fe01 287 st->codec->time_base= (AVRational){1,25};
27e084bd 288 }
4022fe01 289 av_set_pts_info(st, 64, 1, 1200000);
80ce3254 290
de6d9b64
FB
291 return 0;
292}
4c00864f 293#endif
de6d9b64 294
b250f9c6 295#if CONFIG_MPEGVIDEO_DEMUXER
bb270c08
DB
296#define SEQ_START_CODE 0x000001b3
297#define GOP_START_CODE 0x000001b8
298#define PICTURE_START_CODE 0x00000100
93d3e278
MN
299#define SLICE_START_CODE 0x00000101
300#define PACK_START_CODE 0x000001ba
e01dc227
MR
301#define VIDEO_ID 0x000001e0
302#define AUDIO_ID 0x000001c0
c9a65ca8 303
c9a65ca8
FB
304static int mpegvideo_probe(AVProbeData *p)
305{
93d3e278 306 uint32_t code= -1;
e01dc227 307 int pic=0, seq=0, slice=0, pspack=0, pes=0;
93d3e278
MN
308 int i;
309
310 for(i=0; i<p->buf_size; i++){
311 code = (code<<8) + p->buf[i];
312 if ((code & 0xffffff00) == 0x100) {
313 switch(code){
314 case SEQ_START_CODE: seq++; break;
315 case PICTURE_START_CODE: pic++; break;
316 case SLICE_START_CODE: slice++; break;
317 case PACK_START_CODE: pspack++; break;
318 }
e9f6c8ea
MN
319 if ((code & 0x1f0) == VIDEO_ID) pes++;
320 else if((code & 0x1e0) == AUDIO_ID) pes++;
93d3e278 321 }
c9a65ca8 322 }
e01dc227 323 if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
93d3e278 324 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
c9a65ca8
FB
325 return 0;
326}
9f2fc126
SG
327
328#define CAVS_SEQ_START_CODE 0x000001b0
329#define CAVS_PIC_I_START_CODE 0x000001b3
330#define CAVS_UNDEF_START_CODE 0x000001b4
331#define CAVS_PIC_PB_START_CODE 0x000001b6
332#define CAVS_VIDEO_EDIT_CODE 0x000001b7
333#define CAVS_PROFILE_JIZHUN 0x20
334
335static int cavsvideo_probe(AVProbeData *p)
336{
337 uint32_t code= -1;
338 int pic=0, seq=0, slice_pos = 0;
339 int i;
340
341 for(i=0; i<p->buf_size; i++){
342 code = (code<<8) + p->buf[i];
343 if ((code & 0xffffff00) == 0x100) {
344 if(code < CAVS_SEQ_START_CODE) {
345 /* slices have to be consecutive */
346 if(code < slice_pos)
347 return 0;
348 slice_pos = code;
349 } else {
350 slice_pos = 0;
351 }
352 if (code == CAVS_SEQ_START_CODE) {
353 seq++;
354 /* check for the only currently supported profile */
355 if(p->buf[i+1] != CAVS_PROFILE_JIZHUN)
356 return 0;
357 } else if ((code == CAVS_PIC_I_START_CODE) ||
358 (code == CAVS_PIC_PB_START_CODE)) {
359 pic++;
360 } else if ((code == CAVS_UNDEF_START_CODE) ||
361 (code > CAVS_VIDEO_EDIT_CODE)) {
362 return 0;
363 }
364 }
365 }
366 if(seq && seq*9<=pic*10)
367 return AVPROBE_SCORE_MAX/2;
368 return 0;
369}
4c00864f 370#endif
c9a65ca8 371
b250f9c6 372#if CONFIG_M4V_DEMUXER
8f57cc5a
TV
373#define VISUAL_OBJECT_START_CODE 0x000001b5
374#define VOP_START_CODE 0x000001b6
375
376static int mpeg4video_probe(AVProbeData *probe_packet)
377{
378 uint32_t temp_buffer= -1;
5fd5d0ef 379 int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
8f57cc5a
TV
380 int i;
381
382 for(i=0; i<probe_packet->buf_size; i++){
383 temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
c21f308e
RS
384 if ((temp_buffer & 0xffffff00) != 0x100)
385 continue;
386
387 if (temp_buffer == VOP_START_CODE) VOP++;
388 else if (temp_buffer == VISUAL_OBJECT_START_CODE) VISO++;
389 else if (temp_buffer < 0x120) VO++;
390 else if (temp_buffer < 0x130) VOL++;
391 else if ( !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
392 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
8f57cc5a
TV
393 }
394
5fd5d0ef 395 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
8f57cc5a
TV
396 return AVPROBE_SCORE_MAX/2;
397 return 0;
398}
4c00864f 399#endif
8f57cc5a 400
b250f9c6 401#if CONFIG_H264_DEMUXER
010acd8e
MN
402static int h264_probe(AVProbeData *p)
403{
404 uint32_t code= -1;
01037451 405 int sps=0, pps=0, idr=0, res=0, sli=0;
010acd8e
MN
406 int i;
407
408 for(i=0; i<p->buf_size; i++){
409 code = (code<<8) + p->buf[i];
410 if ((code & 0xffffff00) == 0x100) {
411 int ref_idc= (code>>5)&3;
412 int type = code & 0x1F;
413 static const int8_t ref_zero[32]={
414 2, 0, 0, 0, 0,-1, 1,-1,
415 -1, 1, 1, 1, 1,-1, 2, 2,
416 2, 2, 2, 0, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2
418 };
419
420 if(code & 0x80) //forbidden bit
421 return 0;
422
423 if(ref_zero[type] == 1 && ref_idc)
424 return 0;
425 if(ref_zero[type] ==-1 && !ref_idc)
426 return 0;
427 if(ref_zero[type] == 2)
428 res++;
429
430 switch(type){
01037451 431 case 1: sli++; break;
010acd8e
MN
432 case 5: idr++; break;
433 case 7:
434 if(p->buf[i+2]&0x0F)
435 return 0;
436 sps++;
437 break;
438 case 8: pps++; break;
439 }
440 }
441 }
01037451 442 if(sps && pps && (idr||sli>3) && res<(sps+pps+idr))
010acd8e
MN
443 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
444 return 0;
445}
4c00864f 446#endif
010acd8e 447
b250f9c6 448#if CONFIG_H263_DEMUXER
d07f9043
MN
449static int h263_probe(AVProbeData *p)
450{
451 int code;
452 const uint8_t *d;
453
d07f9043
MN
454 d = p->buf;
455 code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
456 if (code == 0x20) {
457 return 50;
458 }
459 return 0;
460}
4c00864f 461#endif
d07f9043 462
b250f9c6 463#if CONFIG_H261_DEMUXER
c6148de2
MN
464static int h261_probe(AVProbeData *p)
465{
466 int code;
467 const uint8_t *d;
468
c6148de2
MN
469 d = p->buf;
470 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
471 if (code == 0x10) {
472 return 50;
473 }
474 return 0;
475}
4c00864f 476#endif
c6148de2 477
b250f9c6 478#if CONFIG_DTS_DEMUXER
fde8052e
BL
479#define DCA_MARKER_14B_BE 0x1FFFE800
480#define DCA_MARKER_14B_LE 0xFF1F00E8
481#define DCA_MARKER_RAW_BE 0x7FFE8001
482#define DCA_MARKER_RAW_LE 0xFE7F0180
483static int dts_probe(AVProbeData *p)
484{
485 const uint8_t *buf, *bufp;
486 uint32_t state = -1;
487
488 buf = p->buf;
489
490 for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
491 bufp = buf;
492 state = (state << 16) | bytestream_get_be16(&bufp);
493
fb9f1117 494 /* regular bitstream */
fde8052e
BL
495 if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
496 return AVPROBE_SCORE_MAX/2+1;
497
fb9f1117 498 /* 14 bits big-endian bitstream */
fde8052e
BL
499 if (state == DCA_MARKER_14B_BE)
500 if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
501 return AVPROBE_SCORE_MAX/2+1;
502
fb9f1117 503 /* 14 bits little-endian bitstream */
fde8052e
BL
504 if (state == DCA_MARKER_14B_LE)
505 if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
506 return AVPROBE_SCORE_MAX/2+1;
507 }
508
509 return 0;
510}
4c00864f 511#endif
fde8052e 512
b250f9c6 513#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
514static int dirac_probe(AVProbeData *p)
515{
516 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
517 return AVPROBE_SCORE_MAX;
518 else
519 return 0;
520}
4c00864f 521#endif
17ac9f1c 522
b250f9c6 523#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
524static int dnxhd_probe(AVProbeData *p)
525{
526 static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
527 if (!memcmp(p->buf, header, 5))
528 return AVPROBE_SCORE_MAX;
529 else
530 return 0;
531}
532#endif
533
b250f9c6 534#if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
75198e7a 535static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
7156aeb9 536{
8c222bb4 537 int max_frames, first_frames = 0, frames;
f8b9830b
JR
538 uint8_t *buf, *buf2, *end;
539 AC3HeaderInfo hdr;
55736cfb 540 GetBitContext gbc;
75198e7a 541 enum CodecID codec_id = CODEC_ID_AC3;
7156aeb9 542
f8b9830b
JR
543 max_frames = 0;
544 buf = p->buf;
ecc8fc11 545 end = buf + p->buf_size;
f8b9830b
JR
546
547 for(; buf < end; buf++) {
548 buf2 = buf;
7156aeb9 549
f8b9830b 550 for(frames = 0; buf2 < end; frames++) {
55736cfb
BW
551 init_get_bits(&gbc, buf2, 54);
552 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
f8b9830b 553 break;
c675ef70
554 if(buf2 + hdr.frame_size > end ||
555 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
556 break;
2988c93d 557 if (hdr.bitstream_id > 10)
75198e7a 558 codec_id = CODEC_ID_EAC3;
f8b9830b
JR
559 buf2 += hdr.frame_size;
560 }
561 max_frames = FFMAX(max_frames, frames);
562 if(buf == p->buf)
563 first_frames = frames;
564 }
75198e7a 565 if(codec_id != expected_codec_id) return 0;
f8b9830b 566 if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
2477ce23 567 else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
f8b9830b
JR
568 else if(max_frames>=1) return 1;
569 else return 0;
7156aeb9 570}
4c00864f 571#endif
7156aeb9 572
b250f9c6 573#if CONFIG_AC3_DEMUXER
2988c93d
JR
574static int ac3_probe(AVProbeData *p)
575{
75198e7a 576 return ac3_eac3_probe(p, CODEC_ID_AC3);
2988c93d
JR
577}
578#endif
579
b250f9c6 580#if CONFIG_EAC3_DEMUXER
2988c93d
JR
581static int eac3_probe(AVProbeData *p)
582{
75198e7a 583 return ac3_eac3_probe(p, CODEC_ID_EAC3);
2988c93d
JR
584}
585#endif
586
b250f9c6 587#if CONFIG_AAC_DEMUXER
2ba0cdd5
MN
588static int adts_aac_probe(AVProbeData *p)
589{
590 int max_frames = 0, first_frames = 0;
591 int fsize, frames;
ac3ef4a4 592 uint8_t *buf0 = p->buf;
2ba0cdd5 593 uint8_t *buf2;
ac3ef4a4
AC
594 uint8_t *buf;
595 uint8_t *end = buf0 + p->buf_size - 7;
596
597 if (ff_id3v2_match(buf0)) {
598 buf0 += ff_id3v2_tag_len(buf0);
599 }
600 buf = buf0;
2ba0cdd5
MN
601
602 for(; buf < end; buf= buf2+1) {
603 buf2 = buf;
604
605 for(frames = 0; buf2 < end; frames++) {
606 uint32_t header = AV_RB16(buf2);
607 if((header&0xFFF6) != 0xFFF0)
608 break;
609 fsize = (AV_RB32(buf2+3)>>13) & 0x8FFF;
610 if(fsize < 7)
611 break;
612 buf2 += fsize;
613 }
614 max_frames = FFMAX(max_frames, frames);
ac3ef4a4 615 if(buf == buf0)
2ba0cdd5
MN
616 first_frames= frames;
617 }
618 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
619 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
620 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
621 else if(max_frames>=1) return 1;
622 else return 0;
623}
624#endif
900eb63d
DB
625
626/* Note: Do not forget to add new entries to the Makefile as well. */
627
b250f9c6 628#if CONFIG_AAC_DEMUXER
76d32428
DB
629AVInputFormat aac_demuxer = {
630 "aac",
b4ee1d39 631 NULL_IF_CONFIG_SMALL("raw ADTS AAC"),
16e861e3 632 0,
2ba0cdd5 633 adts_aac_probe,
16e861e3 634 audio_read_header,
81f052cb 635 ff_raw_read_partial_packet,
16e861e3 636 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
637 .extensions = "aac",
638 .value = CODEC_ID_AAC,
ce1d2a95 639};
7402ee23 640#endif
ce1d2a95 641
b250f9c6 642#if CONFIG_AC3_DEMUXER
d2a067d1 643AVInputFormat ac3_demuxer = {
c9a65ca8 644 "ac3",
bde15e74 645 NULL_IF_CONFIG_SMALL("raw AC-3"),
c9a65ca8 646 0,
7156aeb9 647 ac3_probe,
a0af2fa4 648 audio_read_header,
81f052cb 649 ff_raw_read_partial_packet,
e9b78eeb 650 .flags= AVFMT_GENERIC_INDEX,
bb76a117 651 .extensions = "ac3",
a0af2fa4 652 .value = CODEC_ID_AC3,
de6d9b64 653};
cefd4907 654#endif
de6d9b64 655
b250f9c6 656#if CONFIG_AC3_MUXER
d2a067d1 657AVOutputFormat ac3_muxer = {
de6d9b64 658 "ac3",
bde15e74 659 NULL_IF_CONFIG_SMALL("raw AC-3"),
115329f1 660 "audio/x-ac3",
de6d9b64 661 "ac3",
c9a65ca8 662 0,
de6d9b64 663 CODEC_ID_AC3,
d9133126 664 CODEC_ID_NONE,
7a97dd84 665 NULL,
de6d9b64 666 raw_write_packet,
494bbf58 667 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 668};
082f7acf 669#endif
de6d9b64 670
b250f9c6 671#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
672AVInputFormat dirac_demuxer = {
673 "dirac",
bde15e74 674 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
675 0,
676 dirac_probe,
677 video_read_header,
81f052cb 678 ff_raw_read_partial_packet,
17ac9f1c
LB
679 .flags= AVFMT_GENERIC_INDEX,
680 .value = CODEC_ID_DIRAC,
681};
7402ee23 682#endif
17ac9f1c 683
b250f9c6 684#if CONFIG_DIRAC_MUXER
17ac9f1c
LB
685AVOutputFormat dirac_muxer = {
686 "dirac",
bde15e74 687 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
688 NULL,
689 "drc",
690 0,
d9133126 691 CODEC_ID_NONE,
17ac9f1c
LB
692 CODEC_ID_DIRAC,
693 NULL,
694 raw_write_packet,
695 .flags= AVFMT_NOTIMESTAMPS,
696};
697#endif
698
b250f9c6 699#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
700AVInputFormat dnxhd_demuxer = {
701 "dnxhd",
702 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
703 0,
704 dnxhd_probe,
705 video_read_header,
81f052cb 706 ff_raw_read_partial_packet,
bd09e8a7
BC
707 .flags= AVFMT_GENERIC_INDEX,
708 .value = CODEC_ID_DNXHD,
709};
710#endif
711
b250f9c6 712#if CONFIG_DNXHD_MUXER
bd09e8a7
BC
713AVOutputFormat dnxhd_muxer = {
714 "dnxhd",
715 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
716 NULL,
717 "dnxhd",
718 0,
719 CODEC_ID_NONE,
720 CODEC_ID_DNXHD,
721 NULL,
722 raw_write_packet,
723 .flags= AVFMT_NOTIMESTAMPS,
724};
725#endif
726
b250f9c6 727#if CONFIG_DTS_DEMUXER
d2a067d1 728AVInputFormat dts_demuxer = {
23c99253 729 "dts",
bde15e74 730 NULL_IF_CONFIG_SMALL("raw DTS"),
23c99253 731 0,
fde8052e 732 dts_probe,
a0af2fa4 733 audio_read_header,
81f052cb 734 ff_raw_read_partial_packet,
e9b78eeb 735 .flags= AVFMT_GENERIC_INDEX,
23c99253 736 .extensions = "dts",
a0af2fa4 737 .value = CODEC_ID_DTS,
23c99253 738};
7402ee23 739#endif
23c99253 740
b250f9c6 741#if CONFIG_DTS_MUXER
76d32428
DB
742AVOutputFormat dts_muxer = {
743 "dts",
744 NULL_IF_CONFIG_SMALL("raw DTS"),
745 "audio/x-dca",
746 "dts",
fda885c7 747 0,
76d32428
DB
748 CODEC_ID_DTS,
749 CODEC_ID_NONE,
fda885c7 750 NULL,
76d32428
DB
751 raw_write_packet,
752 .flags= AVFMT_NOTIMESTAMPS,
753};
754#endif
755
b250f9c6 756#if CONFIG_EAC3_DEMUXER
2988c93d
JR
757AVInputFormat eac3_demuxer = {
758 "eac3",
759 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
760 0,
761 eac3_probe,
762 audio_read_header,
81f052cb 763 ff_raw_read_partial_packet,
2988c93d
JR
764 .flags= AVFMT_GENERIC_INDEX,
765 .extensions = "eac3",
766 .value = CODEC_ID_EAC3,
767};
768#endif
769
b250f9c6 770#if CONFIG_EAC3_MUXER
2988c93d
JR
771AVOutputFormat eac3_muxer = {
772 "eac3",
773 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
774 "audio/x-eac3",
775 "eac3",
776 0,
777 CODEC_ID_EAC3,
778 CODEC_ID_NONE,
779 NULL,
780 raw_write_packet,
781 .flags= AVFMT_NOTIMESTAMPS,
782};
783#endif
784
b250f9c6 785#if CONFIG_GSM_DEMUXER
60711e95
MN
786AVInputFormat gsm_demuxer = {
787 "gsm",
b4ee1d39 788 NULL_IF_CONFIG_SMALL("raw GSM"),
60711e95
MN
789 0,
790 NULL,
791 audio_read_header,
81f052cb 792 ff_raw_read_partial_packet,
60711e95
MN
793 .flags= AVFMT_GENERIC_INDEX,
794 .extensions = "gsm",
795 .value = CODEC_ID_GSM,
796};
7402ee23 797#endif
60711e95 798
b250f9c6 799#if CONFIG_H261_DEMUXER
d2a067d1 800AVInputFormat h261_demuxer = {
c6148de2 801 "h261",
bde15e74 802 NULL_IF_CONFIG_SMALL("raw H.261"),
c6148de2
MN
803 0,
804 h261_probe,
805 video_read_header,
81f052cb 806 ff_raw_read_partial_packet,
e9b78eeb 807 .flags= AVFMT_GENERIC_INDEX,
c6148de2
MN
808 .extensions = "h261",
809 .value = CODEC_ID_H261,
810};
7402ee23 811#endif
c6148de2 812
b250f9c6 813#if CONFIG_H261_MUXER
d2a067d1 814AVOutputFormat h261_muxer = {
1c3990db 815 "h261",
bde15e74 816 NULL_IF_CONFIG_SMALL("raw H.261"),
1c3990db
MN
817 "video/x-h261",
818 "h261",
819 0,
d9133126 820 CODEC_ID_NONE,
1c3990db 821 CODEC_ID_H261,
7a97dd84 822 NULL,
1c3990db 823 raw_write_packet,
494bbf58 824 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 825};
082f7acf 826#endif
1c3990db 827
b250f9c6 828#if CONFIG_H263_DEMUXER
d2a067d1 829AVInputFormat h263_demuxer = {
d07f9043 830 "h263",
bde15e74 831 NULL_IF_CONFIG_SMALL("raw H.263"),
d07f9043
MN
832 0,
833 h263_probe,
834 video_read_header,
81f052cb 835 ff_raw_read_partial_packet,
e9b78eeb 836 .flags= AVFMT_GENERIC_INDEX,
d07f9043
MN
837// .extensions = "h263", //FIXME remove after writing mpeg4_probe
838 .value = CODEC_ID_H263,
839};
7402ee23 840#endif
d07f9043 841
b250f9c6 842#if CONFIG_H263_MUXER
d2a067d1 843AVOutputFormat h263_muxer = {
de6d9b64 844 "h263",
bde15e74 845 NULL_IF_CONFIG_SMALL("raw H.263"),
de6d9b64
FB
846 "video/x-h263",
847 "h263",
848 0,
d9133126 849 CODEC_ID_NONE,
de6d9b64 850 CODEC_ID_H263,
7a97dd84 851 NULL,
de6d9b64 852 raw_write_packet,
494bbf58 853 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 854};
082f7acf 855#endif
c9a65ca8 856
b250f9c6 857#if CONFIG_H264_DEMUXER
76d32428
DB
858AVInputFormat h264_demuxer = {
859 "h264",
860 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
861 0,
010acd8e 862 h264_probe,
76d32428 863 video_read_header,
81f052cb 864 ff_raw_read_partial_packet,
76d32428
DB
865 .flags= AVFMT_GENERIC_INDEX,
866 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
867 .value = CODEC_ID_H264,
868};
7402ee23 869#endif
76d32428 870
b250f9c6 871#if CONFIG_H264_MUXER
76d32428
DB
872AVOutputFormat h264_muxer = {
873 "h264",
874 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
875 NULL,
876 "h264",
877 0,
878 CODEC_ID_NONE,
879 CODEC_ID_H264,
880 NULL,
881 raw_write_packet,
882 .flags= AVFMT_NOTIMESTAMPS,
883};
082f7acf 884#endif
76d32428 885
b250f9c6 886#if CONFIG_INGENIENT_DEMUXER
76d32428
DB
887AVInputFormat ingenient_demuxer = {
888 "ingenient",
b4ee1d39 889 NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
76d32428
DB
890 0,
891 NULL,
892 video_read_header,
893 ingenient_read_packet,
894 .flags= AVFMT_GENERIC_INDEX,
895 .extensions = "cgi", // FIXME
896 .value = CODEC_ID_MJPEG,
897};
7402ee23 898#endif
76d32428 899
b250f9c6 900#if CONFIG_M4V_DEMUXER
d2a067d1 901AVInputFormat m4v_demuxer = {
7866eeff 902 "m4v",
bde15e74 903 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
7866eeff 904 0,
fb9f1117 905 mpeg4video_probe, /** probing for MPEG-4 data */
7866eeff 906 video_read_header,
81f052cb 907 ff_raw_read_partial_packet,
e9b78eeb 908 .flags= AVFMT_GENERIC_INDEX,
492322fc 909 .extensions = "m4v",
bb76a117 910 .value = CODEC_ID_MPEG4,
7866eeff 911};
7402ee23 912#endif
7866eeff 913
b250f9c6 914#if CONFIG_M4V_MUXER
d2a067d1 915AVOutputFormat m4v_muxer = {
89b3d7c9 916 "m4v",
bde15e74 917 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
89b3d7c9
MK
918 NULL,
919 "m4v",
920 0,
921 CODEC_ID_NONE,
922 CODEC_ID_MPEG4,
7a97dd84 923 NULL,
89b3d7c9 924 raw_write_packet,
494bbf58 925 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 926};
082f7acf 927#endif
89b3d7c9 928
b250f9c6 929#if CONFIG_MJPEG_DEMUXER
76d32428
DB
930AVInputFormat mjpeg_demuxer = {
931 "mjpeg",
b4ee1d39 932 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
0da71265 933 0,
76d32428 934 NULL,
0da71265 935 video_read_header,
81f052cb 936 ff_raw_read_partial_packet,
e9b78eeb 937 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
938 .extensions = "mjpg,mjpeg",
939 .value = CODEC_ID_MJPEG,
0da71265 940};
7402ee23 941#endif
0da71265 942
b250f9c6 943#if CONFIG_MJPEG_MUXER
76d32428
DB
944AVOutputFormat mjpeg_muxer = {
945 "mjpeg",
b4ee1d39 946 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
76d32428
DB
947 "video/x-mjpeg",
948 "mjpg,mjpeg",
0da71265
MN
949 0,
950 CODEC_ID_NONE,
76d32428 951 CODEC_ID_MJPEG,
7a97dd84 952 NULL,
0da71265 953 raw_write_packet,
494bbf58 954 .flags= AVFMT_NOTIMESTAMPS,
0da71265 955};
082f7acf 956#endif
0da71265 957
b250f9c6 958#if CONFIG_MLP_DEMUXER
76d32428
DB
959AVInputFormat mlp_demuxer = {
960 "mlp",
961 NULL_IF_CONFIG_SMALL("raw MLP"),
c9a65ca8 962 0,
76d32428
DB
963 NULL,
964 audio_read_header,
81f052cb 965 ff_raw_read_partial_packet,
e9b78eeb 966 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
967 .extensions = "mlp",
968 .value = CODEC_ID_MLP,
de6d9b64 969};
7402ee23 970#endif
de6d9b64 971
23d9cc45
RP
972#if CONFIG_TRUEHD_DEMUXER
973AVInputFormat truehd_demuxer = {
974 "truehd",
975 NULL_IF_CONFIG_SMALL("raw TrueHD"),
976 0,
977 NULL,
978 audio_read_header,
979 ff_raw_read_partial_packet,
980 .flags= AVFMT_GENERIC_INDEX,
981 .extensions = "thd",
982 .value = CODEC_ID_TRUEHD,
983};
984#endif
985
986#if CONFIG_TRUEHD_MUXER
987AVOutputFormat truehd_muxer = {
988 "truehd",
989 NULL_IF_CONFIG_SMALL("raw TrueHD"),
990 NULL,
991 "thd",
992 0,
993 CODEC_ID_TRUEHD,
994 CODEC_ID_NONE,
995 NULL,
996 raw_write_packet,
997 .flags= AVFMT_NOTIMESTAMPS,
998};
999#endif
1000
b250f9c6 1001#if CONFIG_MPEG1VIDEO_MUXER
d2a067d1 1002AVOutputFormat mpeg1video_muxer = {
c9a65ca8 1003 "mpeg1video",
b4ee1d39 1004 NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
de6d9b64 1005 "video/x-mpeg",
e0827ba4 1006 "mpg,mpeg,m1v",
de6d9b64 1007 0,
d9133126 1008 CODEC_ID_NONE,
de6d9b64 1009 CODEC_ID_MPEG1VIDEO,
7a97dd84 1010 NULL,
de6d9b64 1011 raw_write_packet,
494bbf58 1012 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 1013};
082f7acf 1014#endif
de6d9b64 1015
b250f9c6 1016#if CONFIG_MPEG2VIDEO_MUXER
d2a067d1 1017AVOutputFormat mpeg2video_muxer = {
6ec864da 1018 "mpeg2video",
b4ee1d39 1019 NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
6ec864da
MN
1020 NULL,
1021 "m2v",
1022 0,
d9133126 1023 CODEC_ID_NONE,
6ec864da 1024 CODEC_ID_MPEG2VIDEO,
7a97dd84 1025 NULL,
6ec864da 1026 raw_write_packet,
494bbf58 1027 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 1028};
082f7acf 1029#endif
6ec864da 1030
b250f9c6 1031#if CONFIG_MPEGVIDEO_DEMUXER
76d32428
DB
1032AVInputFormat mpegvideo_demuxer = {
1033 "mpegvideo",
b4ee1d39 1034 NULL_IF_CONFIG_SMALL("raw MPEG video"),
27e084bd 1035 0,
76d32428 1036 mpegvideo_probe,
27e084bd 1037 video_read_header,
81f052cb 1038 ff_raw_read_partial_packet,
e9b78eeb 1039 .flags= AVFMT_GENERIC_INDEX,
76d32428 1040 .value = CODEC_ID_MPEG1VIDEO,
27e084bd 1041};
7402ee23 1042#endif
27e084bd 1043
9f2fc126
SG
1044#if CONFIG_CAVSVIDEO_DEMUXER
1045AVInputFormat cavsvideo_demuxer = {
1046 "cavsvideo",
b81350a8 1047 NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
9f2fc126
SG
1048 0,
1049 cavsvideo_probe,
1050 video_read_header,
81f052cb 1051 ff_raw_read_partial_packet,
9f2fc126
SG
1052 .flags= AVFMT_GENERIC_INDEX,
1053 .value = CODEC_ID_CAVS,
1054};
1055#endif
1056
b250f9c6 1057#if CONFIG_NULL_MUXER
76d32428
DB
1058AVOutputFormat null_muxer = {
1059 "null",
b4ee1d39 1060 NULL_IF_CONFIG_SMALL("raw null video format"),
76d32428
DB
1061 NULL,
1062 NULL,
84c63c01 1063 0,
76d32428
DB
1064#ifdef WORDS_BIGENDIAN
1065 CODEC_ID_PCM_S16BE,
1066#else
1067 CODEC_ID_PCM_S16LE,
1068#endif
1069 CODEC_ID_RAWVIDEO,
84c63c01 1070 NULL,
76d32428
DB
1071 null_write_packet,
1072 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
1073};
082f7acf 1074#endif
76d32428 1075
b250f9c6 1076#if CONFIG_RAWVIDEO_DEMUXER
76d32428
DB
1077AVInputFormat rawvideo_demuxer = {
1078 "rawvideo",
1079 NULL_IF_CONFIG_SMALL("raw video format"),
1080 0,
1081 NULL,
1082 raw_read_header,
1083 rawvideo_read_packet,
e9b78eeb 1084 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
1085 .extensions = "yuv,cif,qcif,rgb",
1086 .value = CODEC_ID_RAWVIDEO,
84c63c01 1087};
7402ee23 1088#endif
84c63c01 1089
b250f9c6 1090#if CONFIG_RAWVIDEO_MUXER
76d32428
DB
1091AVOutputFormat rawvideo_muxer = {
1092 "rawvideo",
1093 NULL_IF_CONFIG_SMALL("raw video format"),
1094 NULL,
1095 "yuv,rgb",
5ed8fafc 1096 0,
d9133126 1097 CODEC_ID_NONE,
76d32428 1098 CODEC_ID_RAWVIDEO,
7a97dd84 1099 NULL,
5ed8fafc 1100 raw_write_packet,
494bbf58 1101 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 1102};
082f7acf 1103#endif
5ed8fafc 1104
b250f9c6 1105#if CONFIG_ROQ_MUXER
76d32428
DB
1106AVOutputFormat roq_muxer =
1107{
1108 "RoQ",
b4ee1d39 1109 NULL_IF_CONFIG_SMALL("raw id RoQ format"),
76d32428
DB
1110 NULL,
1111 "roq",
1112 0,
1113 CODEC_ID_ROQ_DPCM,
1114 CODEC_ID_ROQ,
1115 roq_write_header,
1116 raw_write_packet,
1117};
082f7acf 1118#endif
76d32428 1119
b250f9c6 1120#if CONFIG_SHORTEN_DEMUXER
76d32428
DB
1121AVInputFormat shorten_demuxer = {
1122 "shn",
1123 NULL_IF_CONFIG_SMALL("raw Shorten"),
1124 0,
1125 NULL,
1126 audio_read_header,
81f052cb 1127 ff_raw_read_partial_packet,
76d32428
DB
1128 .flags= AVFMT_GENERIC_INDEX,
1129 .extensions = "shn",
1130 .value = CODEC_ID_SHORTEN,
1131};
7402ee23 1132#endif
76d32428 1133
b250f9c6 1134#if CONFIG_VC1_DEMUXER
7bb5c2a6
KS
1135AVInputFormat vc1_demuxer = {
1136 "vc1",
bde15e74 1137 NULL_IF_CONFIG_SMALL("raw VC-1"),
7bb5c2a6
KS
1138 0,
1139 NULL /* vc1_probe */,
1140 video_read_header,
81f052cb 1141 ff_raw_read_partial_packet,
7bb5c2a6
KS
1142 .extensions = "vc1",
1143 .value = CODEC_ID_VC1,
1144};
7402ee23 1145#endif
7bb5c2a6 1146
fb9f1117 1147/* PCM formats */
764ef400 1148
4986a429 1149#define PCMINPUTDEF(name, long_name, ext, codec) \
d2a067d1 1150AVInputFormat pcm_ ## name ## _demuxer = {\
764ef400 1151 #name,\
bde15e74 1152 NULL_IF_CONFIG_SMALL(long_name),\
764ef400
MM
1153 0,\
1154 NULL,\
1155 raw_read_header,\
1156 raw_read_packet,\
9b64a036 1157 NULL,\
4986a429 1158 pcm_read_seek,\
e9b78eeb 1159 .flags= AVFMT_GENERIC_INDEX,\
764ef400
MM
1160 .extensions = ext,\
1161 .value = codec,\
1162};
1163
2c8e2014 1164#define PCMOUTPUTDEF(name, long_name, ext, codec) \
d2a067d1 1165AVOutputFormat pcm_ ## name ## _muxer = {\
c9a65ca8 1166 #name,\
bde15e74 1167 NULL_IF_CONFIG_SMALL(long_name),\
c9a65ca8
FB
1168 NULL,\
1169 ext,\
1170 0,\
1171 codec,\
d9133126 1172 CODEC_ID_NONE,\
7a97dd84 1173 NULL,\
c9a65ca8 1174 raw_write_packet,\
494bbf58 1175 .flags= AVFMT_NOTIMESTAMPS,\
5ed8fafc 1176};
2c8e2014
DB
1177
1178
b250f9c6 1179#if !CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
1180#define PCMDEF(name, long_name, ext, codec) \
1181 PCMINPUTDEF(name, long_name, ext, codec)
b250f9c6 1182#elif CONFIG_MUXERS && !CONFIG_DEMUXERS
2c8e2014
DB
1183#define PCMDEF(name, long_name, ext, codec) \
1184 PCMOUTPUTDEF(name, long_name, ext, codec)
b250f9c6 1185#elif CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
1186#define PCMDEF(name, long_name, ext, codec) \
1187 PCMINPUTDEF(name, long_name, ext, codec)\
1188 PCMOUTPUTDEF(name, long_name, ext, codec)
1189#else
1190#define PCMDEF(name, long_name, ext, codec)
1191#endif
5ed8fafc 1192
5ed8fafc 1193#ifdef WORDS_BIGENDIAN
c9a65ca8
FB
1194#define BE_DEF(s) s
1195#define LE_DEF(s) NULL
5ed8fafc 1196#else
c9a65ca8
FB
1197#define BE_DEF(s) NULL
1198#define LE_DEF(s) s
5ed8fafc 1199#endif
5ed8fafc 1200
ee7948cb
PR
1201PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
1202 NULL, CODEC_ID_PCM_F64BE)
1203
1204PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
1205 NULL, CODEC_ID_PCM_F64LE)
1206
1207PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
1208 NULL, CODEC_ID_PCM_F32BE)
1209
1210PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
1211 NULL, CODEC_ID_PCM_F32LE)
1212
1213PCMDEF(s32be, "PCM signed 32 bit big-endian format",
1214 NULL, CODEC_ID_PCM_S32BE)
1215
1216PCMDEF(s32le, "PCM signed 32 bit little-endian format",
1217 NULL, CODEC_ID_PCM_S32LE)
1218
1219PCMDEF(s24be, "PCM signed 24 bit big-endian format",
1220 NULL, CODEC_ID_PCM_S24BE)
1221
1222PCMDEF(s24le, "PCM signed 24 bit little-endian format",
1223 NULL, CODEC_ID_PCM_S24LE)
5ed8fafc 1224
ac1ea66e 1225PCMDEF(s16be, "PCM signed 16 bit big-endian format",
c9a65ca8 1226 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 1227
76d32428
DB
1228PCMDEF(s16le, "PCM signed 16 bit little-endian format",
1229 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
1230
1231PCMDEF(s8, "PCM signed 8 bit format",
1232 "sb", CODEC_ID_PCM_S8)
5ed8fafc 1233
ee7948cb
PR
1234PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
1235 NULL, CODEC_ID_PCM_U32BE)
1236
1237PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
1238 NULL, CODEC_ID_PCM_U32LE)
1239
1240PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
1241 NULL, CODEC_ID_PCM_U24BE)
1242
1243PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
1244 NULL, CODEC_ID_PCM_U24LE)
1245
ac1ea66e 1246PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
c9a65ca8 1247 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 1248
76d32428
DB
1249PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
1250 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 1251
ac1ea66e 1252PCMDEF(u8, "PCM unsigned 8 bit format",
c9a65ca8 1253 "ub", CODEC_ID_PCM_U8)
5ed8fafc 1254
ac1ea66e 1255PCMDEF(alaw, "PCM A-law format",
c9a65ca8 1256 "al", CODEC_ID_PCM_ALAW)
de6d9b64 1257
76d32428
DB
1258PCMDEF(mulaw, "PCM mu-law format",
1259 "ul", CODEC_ID_PCM_MULAW)