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