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