Make DTS probe more robust against false positives (as e.g. probetest shows).
[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{
e4c01d40
MN
458 uint64_t code= -1;
459 int i;
460 int valid_psc=0;
461 int invalid_psc=0;
462 int res_change=0;
463 int src_fmt, last_src_fmt=-1;
d07f9043 464
e4c01d40
MN
465 for(i=0; i<p->buf_size; i++){
466 code = (code<<8) + p->buf[i];
467 if ((code & 0xfffffc0000) == 0x800000) {
468 src_fmt= (code>>2)&3;
469 if( src_fmt != last_src_fmt
470 && last_src_fmt>0 && last_src_fmt<6
471 && src_fmt<6)
472 res_change++;
473
474 if((code&0x300)==0x200 && src_fmt){
475 valid_psc++;
476 }else
477 invalid_psc++;
478 last_src_fmt= src_fmt;
479 }
d07f9043 480 }
e4c01d40
MN
481 if(valid_psc > 2*invalid_psc + 2*res_change + 2){
482 return 50;
483 }else if(valid_psc > 2*invalid_psc)
484 return 25;
d07f9043
MN
485 return 0;
486}
4c00864f 487#endif
d07f9043 488
b250f9c6 489#if CONFIG_H261_DEMUXER
c6148de2
MN
490static int h261_probe(AVProbeData *p)
491{
492 int code;
493 const uint8_t *d;
494
c6148de2
MN
495 d = p->buf;
496 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
497 if (code == 0x10) {
498 return 50;
499 }
500 return 0;
501}
4c00864f 502#endif
c6148de2 503
b250f9c6 504#if CONFIG_DTS_DEMUXER
fde8052e
BL
505#define DCA_MARKER_14B_BE 0x1FFFE800
506#define DCA_MARKER_14B_LE 0xFF1F00E8
507#define DCA_MARKER_RAW_BE 0x7FFE8001
508#define DCA_MARKER_RAW_LE 0xFE7F0180
509static int dts_probe(AVProbeData *p)
510{
511 const uint8_t *buf, *bufp;
512 uint32_t state = -1;
05bdd33a
RD
513 int markers[3] = {0};
514 int sum, max;
fde8052e
BL
515
516 buf = p->buf;
517
518 for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
519 bufp = buf;
520 state = (state << 16) | bytestream_get_be16(&bufp);
521
fb9f1117 522 /* regular bitstream */
fde8052e 523 if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
05bdd33a 524 markers[0]++;
fde8052e 525
fb9f1117 526 /* 14 bits big-endian bitstream */
fde8052e
BL
527 if (state == DCA_MARKER_14B_BE)
528 if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
05bdd33a 529 markers[1]++;
fde8052e 530
fb9f1117 531 /* 14 bits little-endian bitstream */
fde8052e
BL
532 if (state == DCA_MARKER_14B_LE)
533 if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
05bdd33a 534 markers[2]++;
fde8052e 535 }
05bdd33a
RD
536 sum = markers[0] + markers[1] + markers[2];
537 max = markers[1] > markers[0];
538 max = markers[2] > markers[max] ? 2 : max;
539 if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
540 markers[max] * 4 > sum * 3)
541 return AVPROBE_SCORE_MAX/2+1;
fde8052e
BL
542
543 return 0;
544}
4c00864f 545#endif
fde8052e 546
b250f9c6 547#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
548static int dirac_probe(AVProbeData *p)
549{
550 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
551 return AVPROBE_SCORE_MAX;
552 else
553 return 0;
554}
4c00864f 555#endif
17ac9f1c 556
b250f9c6 557#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
558static int dnxhd_probe(AVProbeData *p)
559{
560 static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
561 if (!memcmp(p->buf, header, 5))
562 return AVPROBE_SCORE_MAX;
563 else
564 return 0;
565}
566#endif
567
b250f9c6 568#if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
75198e7a 569static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
7156aeb9 570{
8c222bb4 571 int max_frames, first_frames = 0, frames;
f8b9830b
JR
572 uint8_t *buf, *buf2, *end;
573 AC3HeaderInfo hdr;
55736cfb 574 GetBitContext gbc;
75198e7a 575 enum CodecID codec_id = CODEC_ID_AC3;
7156aeb9 576
f8b9830b
JR
577 max_frames = 0;
578 buf = p->buf;
ecc8fc11 579 end = buf + p->buf_size;
f8b9830b
JR
580
581 for(; buf < end; buf++) {
582 buf2 = buf;
7156aeb9 583
f8b9830b 584 for(frames = 0; buf2 < end; frames++) {
55736cfb
BW
585 init_get_bits(&gbc, buf2, 54);
586 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
f8b9830b 587 break;
c675ef70
588 if(buf2 + hdr.frame_size > end ||
589 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
590 break;
2988c93d 591 if (hdr.bitstream_id > 10)
75198e7a 592 codec_id = CODEC_ID_EAC3;
f8b9830b
JR
593 buf2 += hdr.frame_size;
594 }
595 max_frames = FFMAX(max_frames, frames);
596 if(buf == p->buf)
597 first_frames = frames;
598 }
75198e7a 599 if(codec_id != expected_codec_id) return 0;
f8b9830b 600 if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
2477ce23 601 else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
f8b9830b
JR
602 else if(max_frames>=1) return 1;
603 else return 0;
7156aeb9 604}
4c00864f 605#endif
7156aeb9 606
b250f9c6 607#if CONFIG_AC3_DEMUXER
2988c93d
JR
608static int ac3_probe(AVProbeData *p)
609{
75198e7a 610 return ac3_eac3_probe(p, CODEC_ID_AC3);
2988c93d
JR
611}
612#endif
613
b250f9c6 614#if CONFIG_EAC3_DEMUXER
2988c93d
JR
615static int eac3_probe(AVProbeData *p)
616{
75198e7a 617 return ac3_eac3_probe(p, CODEC_ID_EAC3);
2988c93d
JR
618}
619#endif
620
b250f9c6 621#if CONFIG_AAC_DEMUXER
2ba0cdd5
MN
622static int adts_aac_probe(AVProbeData *p)
623{
624 int max_frames = 0, first_frames = 0;
625 int fsize, frames;
ac3ef4a4 626 uint8_t *buf0 = p->buf;
2ba0cdd5 627 uint8_t *buf2;
ac3ef4a4
AC
628 uint8_t *buf;
629 uint8_t *end = buf0 + p->buf_size - 7;
630
631 if (ff_id3v2_match(buf0)) {
632 buf0 += ff_id3v2_tag_len(buf0);
633 }
634 buf = buf0;
2ba0cdd5
MN
635
636 for(; buf < end; buf= buf2+1) {
637 buf2 = buf;
638
639 for(frames = 0; buf2 < end; frames++) {
640 uint32_t header = AV_RB16(buf2);
641 if((header&0xFFF6) != 0xFFF0)
642 break;
643 fsize = (AV_RB32(buf2+3)>>13) & 0x8FFF;
644 if(fsize < 7)
645 break;
646 buf2 += fsize;
647 }
648 max_frames = FFMAX(max_frames, frames);
ac3ef4a4 649 if(buf == buf0)
2ba0cdd5
MN
650 first_frames= frames;
651 }
652 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
653 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
654 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
655 else if(max_frames>=1) return 1;
656 else return 0;
657}
d52b90bd
PD
658
659static int adts_aac_read_header(AVFormatContext *s,
660 AVFormatParameters *ap)
661{
662 AVStream *st;
663
664 st = av_new_stream(s, 0);
665 if (!st)
666 return AVERROR(ENOMEM);
667
668 st->codec->codec_type = CODEC_TYPE_AUDIO;
669 st->codec->codec_id = s->iformat->value;
670 st->need_parsing = AVSTREAM_PARSE_FULL;
671
672 ff_id3v1_read(s);
673 ff_id3v2_read(s);
674
675 return 0;
676}
677
2ba0cdd5 678#endif
900eb63d
DB
679
680/* Note: Do not forget to add new entries to the Makefile as well. */
681
b250f9c6 682#if CONFIG_AAC_DEMUXER
76d32428
DB
683AVInputFormat aac_demuxer = {
684 "aac",
b4ee1d39 685 NULL_IF_CONFIG_SMALL("raw ADTS AAC"),
16e861e3 686 0,
2ba0cdd5 687 adts_aac_probe,
d52b90bd 688 adts_aac_read_header,
81f052cb 689 ff_raw_read_partial_packet,
16e861e3 690 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
691 .extensions = "aac",
692 .value = CODEC_ID_AAC,
ce1d2a95 693};
7402ee23 694#endif
ce1d2a95 695
b250f9c6 696#if CONFIG_AC3_DEMUXER
d2a067d1 697AVInputFormat ac3_demuxer = {
c9a65ca8 698 "ac3",
bde15e74 699 NULL_IF_CONFIG_SMALL("raw AC-3"),
c9a65ca8 700 0,
7156aeb9 701 ac3_probe,
a0af2fa4 702 audio_read_header,
81f052cb 703 ff_raw_read_partial_packet,
e9b78eeb 704 .flags= AVFMT_GENERIC_INDEX,
bb76a117 705 .extensions = "ac3",
a0af2fa4 706 .value = CODEC_ID_AC3,
de6d9b64 707};
cefd4907 708#endif
de6d9b64 709
b250f9c6 710#if CONFIG_AC3_MUXER
d2a067d1 711AVOutputFormat ac3_muxer = {
de6d9b64 712 "ac3",
bde15e74 713 NULL_IF_CONFIG_SMALL("raw AC-3"),
115329f1 714 "audio/x-ac3",
de6d9b64 715 "ac3",
c9a65ca8 716 0,
de6d9b64 717 CODEC_ID_AC3,
d9133126 718 CODEC_ID_NONE,
7a97dd84 719 NULL,
de6d9b64 720 raw_write_packet,
494bbf58 721 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 722};
082f7acf 723#endif
de6d9b64 724
b250f9c6 725#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
726AVInputFormat dirac_demuxer = {
727 "dirac",
bde15e74 728 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
729 0,
730 dirac_probe,
731 video_read_header,
81f052cb 732 ff_raw_read_partial_packet,
17ac9f1c
LB
733 .flags= AVFMT_GENERIC_INDEX,
734 .value = CODEC_ID_DIRAC,
735};
7402ee23 736#endif
17ac9f1c 737
b250f9c6 738#if CONFIG_DIRAC_MUXER
17ac9f1c
LB
739AVOutputFormat dirac_muxer = {
740 "dirac",
bde15e74 741 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
742 NULL,
743 "drc",
744 0,
d9133126 745 CODEC_ID_NONE,
17ac9f1c
LB
746 CODEC_ID_DIRAC,
747 NULL,
748 raw_write_packet,
749 .flags= AVFMT_NOTIMESTAMPS,
750};
751#endif
752
b250f9c6 753#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
754AVInputFormat dnxhd_demuxer = {
755 "dnxhd",
756 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
757 0,
758 dnxhd_probe,
759 video_read_header,
81f052cb 760 ff_raw_read_partial_packet,
bd09e8a7
BC
761 .flags= AVFMT_GENERIC_INDEX,
762 .value = CODEC_ID_DNXHD,
763};
764#endif
765
b250f9c6 766#if CONFIG_DNXHD_MUXER
bd09e8a7
BC
767AVOutputFormat dnxhd_muxer = {
768 "dnxhd",
769 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
770 NULL,
771 "dnxhd",
772 0,
773 CODEC_ID_NONE,
774 CODEC_ID_DNXHD,
775 NULL,
776 raw_write_packet,
777 .flags= AVFMT_NOTIMESTAMPS,
778};
779#endif
780
b250f9c6 781#if CONFIG_DTS_DEMUXER
d2a067d1 782AVInputFormat dts_demuxer = {
23c99253 783 "dts",
bde15e74 784 NULL_IF_CONFIG_SMALL("raw DTS"),
23c99253 785 0,
fde8052e 786 dts_probe,
a0af2fa4 787 audio_read_header,
81f052cb 788 ff_raw_read_partial_packet,
e9b78eeb 789 .flags= AVFMT_GENERIC_INDEX,
23c99253 790 .extensions = "dts",
a0af2fa4 791 .value = CODEC_ID_DTS,
23c99253 792};
7402ee23 793#endif
23c99253 794
b250f9c6 795#if CONFIG_DTS_MUXER
76d32428
DB
796AVOutputFormat dts_muxer = {
797 "dts",
798 NULL_IF_CONFIG_SMALL("raw DTS"),
799 "audio/x-dca",
800 "dts",
fda885c7 801 0,
76d32428
DB
802 CODEC_ID_DTS,
803 CODEC_ID_NONE,
fda885c7 804 NULL,
76d32428
DB
805 raw_write_packet,
806 .flags= AVFMT_NOTIMESTAMPS,
807};
808#endif
809
b250f9c6 810#if CONFIG_EAC3_DEMUXER
2988c93d
JR
811AVInputFormat eac3_demuxer = {
812 "eac3",
813 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
814 0,
815 eac3_probe,
816 audio_read_header,
81f052cb 817 ff_raw_read_partial_packet,
2988c93d
JR
818 .flags= AVFMT_GENERIC_INDEX,
819 .extensions = "eac3",
820 .value = CODEC_ID_EAC3,
821};
822#endif
823
b250f9c6 824#if CONFIG_EAC3_MUXER
2988c93d
JR
825AVOutputFormat eac3_muxer = {
826 "eac3",
827 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
828 "audio/x-eac3",
829 "eac3",
830 0,
831 CODEC_ID_EAC3,
832 CODEC_ID_NONE,
833 NULL,
834 raw_write_packet,
835 .flags= AVFMT_NOTIMESTAMPS,
836};
837#endif
838
b250f9c6 839#if CONFIG_GSM_DEMUXER
60711e95
MN
840AVInputFormat gsm_demuxer = {
841 "gsm",
b4ee1d39 842 NULL_IF_CONFIG_SMALL("raw GSM"),
60711e95
MN
843 0,
844 NULL,
845 audio_read_header,
81f052cb 846 ff_raw_read_partial_packet,
60711e95
MN
847 .flags= AVFMT_GENERIC_INDEX,
848 .extensions = "gsm",
849 .value = CODEC_ID_GSM,
850};
7402ee23 851#endif
60711e95 852
b250f9c6 853#if CONFIG_H261_DEMUXER
d2a067d1 854AVInputFormat h261_demuxer = {
c6148de2 855 "h261",
bde15e74 856 NULL_IF_CONFIG_SMALL("raw H.261"),
c6148de2
MN
857 0,
858 h261_probe,
859 video_read_header,
81f052cb 860 ff_raw_read_partial_packet,
e9b78eeb 861 .flags= AVFMT_GENERIC_INDEX,
c6148de2
MN
862 .extensions = "h261",
863 .value = CODEC_ID_H261,
864};
7402ee23 865#endif
c6148de2 866
b250f9c6 867#if CONFIG_H261_MUXER
d2a067d1 868AVOutputFormat h261_muxer = {
1c3990db 869 "h261",
bde15e74 870 NULL_IF_CONFIG_SMALL("raw H.261"),
1c3990db
MN
871 "video/x-h261",
872 "h261",
873 0,
d9133126 874 CODEC_ID_NONE,
1c3990db 875 CODEC_ID_H261,
7a97dd84 876 NULL,
1c3990db 877 raw_write_packet,
494bbf58 878 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 879};
082f7acf 880#endif
1c3990db 881
b250f9c6 882#if CONFIG_H263_DEMUXER
d2a067d1 883AVInputFormat h263_demuxer = {
d07f9043 884 "h263",
bde15e74 885 NULL_IF_CONFIG_SMALL("raw H.263"),
d07f9043
MN
886 0,
887 h263_probe,
888 video_read_header,
81f052cb 889 ff_raw_read_partial_packet,
e9b78eeb 890 .flags= AVFMT_GENERIC_INDEX,
d07f9043
MN
891// .extensions = "h263", //FIXME remove after writing mpeg4_probe
892 .value = CODEC_ID_H263,
893};
7402ee23 894#endif
d07f9043 895
b250f9c6 896#if CONFIG_H263_MUXER
d2a067d1 897AVOutputFormat h263_muxer = {
de6d9b64 898 "h263",
bde15e74 899 NULL_IF_CONFIG_SMALL("raw H.263"),
de6d9b64
FB
900 "video/x-h263",
901 "h263",
902 0,
d9133126 903 CODEC_ID_NONE,
de6d9b64 904 CODEC_ID_H263,
7a97dd84 905 NULL,
de6d9b64 906 raw_write_packet,
494bbf58 907 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 908};
082f7acf 909#endif
c9a65ca8 910
b250f9c6 911#if CONFIG_H264_DEMUXER
76d32428
DB
912AVInputFormat h264_demuxer = {
913 "h264",
914 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
915 0,
010acd8e 916 h264_probe,
76d32428 917 video_read_header,
81f052cb 918 ff_raw_read_partial_packet,
76d32428
DB
919 .flags= AVFMT_GENERIC_INDEX,
920 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
921 .value = CODEC_ID_H264,
922};
7402ee23 923#endif
76d32428 924
b250f9c6 925#if CONFIG_H264_MUXER
76d32428
DB
926AVOutputFormat h264_muxer = {
927 "h264",
928 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
929 NULL,
930 "h264",
931 0,
932 CODEC_ID_NONE,
933 CODEC_ID_H264,
934 NULL,
935 raw_write_packet,
936 .flags= AVFMT_NOTIMESTAMPS,
937};
082f7acf 938#endif
76d32428 939
b250f9c6 940#if CONFIG_INGENIENT_DEMUXER
76d32428
DB
941AVInputFormat ingenient_demuxer = {
942 "ingenient",
b4ee1d39 943 NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
76d32428
DB
944 0,
945 NULL,
946 video_read_header,
947 ingenient_read_packet,
948 .flags= AVFMT_GENERIC_INDEX,
949 .extensions = "cgi", // FIXME
950 .value = CODEC_ID_MJPEG,
951};
7402ee23 952#endif
76d32428 953
b250f9c6 954#if CONFIG_M4V_DEMUXER
d2a067d1 955AVInputFormat m4v_demuxer = {
7866eeff 956 "m4v",
bde15e74 957 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
7866eeff 958 0,
fb9f1117 959 mpeg4video_probe, /** probing for MPEG-4 data */
7866eeff 960 video_read_header,
81f052cb 961 ff_raw_read_partial_packet,
e9b78eeb 962 .flags= AVFMT_GENERIC_INDEX,
492322fc 963 .extensions = "m4v",
bb76a117 964 .value = CODEC_ID_MPEG4,
7866eeff 965};
7402ee23 966#endif
7866eeff 967
b250f9c6 968#if CONFIG_M4V_MUXER
d2a067d1 969AVOutputFormat m4v_muxer = {
89b3d7c9 970 "m4v",
bde15e74 971 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
89b3d7c9
MK
972 NULL,
973 "m4v",
974 0,
975 CODEC_ID_NONE,
976 CODEC_ID_MPEG4,
7a97dd84 977 NULL,
89b3d7c9 978 raw_write_packet,
494bbf58 979 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 980};
082f7acf 981#endif
89b3d7c9 982
b250f9c6 983#if CONFIG_MJPEG_DEMUXER
76d32428
DB
984AVInputFormat mjpeg_demuxer = {
985 "mjpeg",
b4ee1d39 986 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
0da71265 987 0,
76d32428 988 NULL,
0da71265 989 video_read_header,
81f052cb 990 ff_raw_read_partial_packet,
e9b78eeb 991 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
992 .extensions = "mjpg,mjpeg",
993 .value = CODEC_ID_MJPEG,
0da71265 994};
7402ee23 995#endif
0da71265 996
b250f9c6 997#if CONFIG_MJPEG_MUXER
76d32428
DB
998AVOutputFormat mjpeg_muxer = {
999 "mjpeg",
b4ee1d39 1000 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
76d32428
DB
1001 "video/x-mjpeg",
1002 "mjpg,mjpeg",
0da71265
MN
1003 0,
1004 CODEC_ID_NONE,
76d32428 1005 CODEC_ID_MJPEG,
7a97dd84 1006 NULL,
0da71265 1007 raw_write_packet,
494bbf58 1008 .flags= AVFMT_NOTIMESTAMPS,
0da71265 1009};
082f7acf 1010#endif
0da71265 1011
b250f9c6 1012#if CONFIG_MLP_DEMUXER
76d32428
DB
1013AVInputFormat mlp_demuxer = {
1014 "mlp",
1015 NULL_IF_CONFIG_SMALL("raw MLP"),
c9a65ca8 1016 0,
76d32428
DB
1017 NULL,
1018 audio_read_header,
81f052cb 1019 ff_raw_read_partial_packet,
e9b78eeb 1020 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
1021 .extensions = "mlp",
1022 .value = CODEC_ID_MLP,
de6d9b64 1023};
7402ee23 1024#endif
de6d9b64 1025
0e1ccdeb 1026#if CONFIG_MLP_MUXER
9145021d
RP
1027AVOutputFormat mlp_muxer = {
1028 "mlp",
1029 NULL_IF_CONFIG_SMALL("raw MLP"),
1030 NULL,
1031 "mlp",
1032 0,
1033 CODEC_ID_MLP,
1034 CODEC_ID_NONE,
1035 NULL,
1036 raw_write_packet,
1037 .flags= AVFMT_NOTIMESTAMPS,
1038};
1039#endif
1040
23d9cc45
RP
1041#if CONFIG_TRUEHD_DEMUXER
1042AVInputFormat truehd_demuxer = {
1043 "truehd",
1044 NULL_IF_CONFIG_SMALL("raw TrueHD"),
1045 0,
1046 NULL,
1047 audio_read_header,
1048 ff_raw_read_partial_packet,
1049 .flags= AVFMT_GENERIC_INDEX,
1050 .extensions = "thd",
1051 .value = CODEC_ID_TRUEHD,
1052};
1053#endif
1054
1055#if CONFIG_TRUEHD_MUXER
1056AVOutputFormat truehd_muxer = {
1057 "truehd",
1058 NULL_IF_CONFIG_SMALL("raw TrueHD"),
1059 NULL,
1060 "thd",
1061 0,
1062 CODEC_ID_TRUEHD,
1063 CODEC_ID_NONE,
1064 NULL,
1065 raw_write_packet,
1066 .flags= AVFMT_NOTIMESTAMPS,
1067};
1068#endif
1069
b250f9c6 1070#if CONFIG_MPEG1VIDEO_MUXER
d2a067d1 1071AVOutputFormat mpeg1video_muxer = {
c9a65ca8 1072 "mpeg1video",
b4ee1d39 1073 NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
de6d9b64 1074 "video/x-mpeg",
e0827ba4 1075 "mpg,mpeg,m1v",
de6d9b64 1076 0,
d9133126 1077 CODEC_ID_NONE,
de6d9b64 1078 CODEC_ID_MPEG1VIDEO,
7a97dd84 1079 NULL,
de6d9b64 1080 raw_write_packet,
494bbf58 1081 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 1082};
082f7acf 1083#endif
de6d9b64 1084
b250f9c6 1085#if CONFIG_MPEG2VIDEO_MUXER
d2a067d1 1086AVOutputFormat mpeg2video_muxer = {
6ec864da 1087 "mpeg2video",
b4ee1d39 1088 NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
6ec864da
MN
1089 NULL,
1090 "m2v",
1091 0,
d9133126 1092 CODEC_ID_NONE,
6ec864da 1093 CODEC_ID_MPEG2VIDEO,
7a97dd84 1094 NULL,
6ec864da 1095 raw_write_packet,
494bbf58 1096 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 1097};
082f7acf 1098#endif
6ec864da 1099
b250f9c6 1100#if CONFIG_MPEGVIDEO_DEMUXER
76d32428
DB
1101AVInputFormat mpegvideo_demuxer = {
1102 "mpegvideo",
b4ee1d39 1103 NULL_IF_CONFIG_SMALL("raw MPEG video"),
27e084bd 1104 0,
76d32428 1105 mpegvideo_probe,
27e084bd 1106 video_read_header,
81f052cb 1107 ff_raw_read_partial_packet,
e9b78eeb 1108 .flags= AVFMT_GENERIC_INDEX,
76d32428 1109 .value = CODEC_ID_MPEG1VIDEO,
27e084bd 1110};
7402ee23 1111#endif
27e084bd 1112
9f2fc126
SG
1113#if CONFIG_CAVSVIDEO_DEMUXER
1114AVInputFormat cavsvideo_demuxer = {
1115 "cavsvideo",
b81350a8 1116 NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
9f2fc126
SG
1117 0,
1118 cavsvideo_probe,
1119 video_read_header,
81f052cb 1120 ff_raw_read_partial_packet,
9f2fc126
SG
1121 .flags= AVFMT_GENERIC_INDEX,
1122 .value = CODEC_ID_CAVS,
1123};
1124#endif
1125
b250f9c6 1126#if CONFIG_NULL_MUXER
76d32428
DB
1127AVOutputFormat null_muxer = {
1128 "null",
b4ee1d39 1129 NULL_IF_CONFIG_SMALL("raw null video format"),
76d32428
DB
1130 NULL,
1131 NULL,
84c63c01 1132 0,
63613fe6 1133#if HAVE_BIGENDIAN
76d32428
DB
1134 CODEC_ID_PCM_S16BE,
1135#else
1136 CODEC_ID_PCM_S16LE,
1137#endif
1138 CODEC_ID_RAWVIDEO,
84c63c01 1139 NULL,
76d32428
DB
1140 null_write_packet,
1141 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
1142};
082f7acf 1143#endif
76d32428 1144
b250f9c6 1145#if CONFIG_RAWVIDEO_DEMUXER
76d32428
DB
1146AVInputFormat rawvideo_demuxer = {
1147 "rawvideo",
1148 NULL_IF_CONFIG_SMALL("raw video format"),
1149 0,
1150 NULL,
1151 raw_read_header,
1152 rawvideo_read_packet,
e9b78eeb 1153 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
1154 .extensions = "yuv,cif,qcif,rgb",
1155 .value = CODEC_ID_RAWVIDEO,
84c63c01 1156};
7402ee23 1157#endif
84c63c01 1158
b250f9c6 1159#if CONFIG_RAWVIDEO_MUXER
76d32428
DB
1160AVOutputFormat rawvideo_muxer = {
1161 "rawvideo",
1162 NULL_IF_CONFIG_SMALL("raw video format"),
1163 NULL,
1164 "yuv,rgb",
5ed8fafc 1165 0,
d9133126 1166 CODEC_ID_NONE,
76d32428 1167 CODEC_ID_RAWVIDEO,
7a97dd84 1168 NULL,
5ed8fafc 1169 raw_write_packet,
494bbf58 1170 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 1171};
082f7acf 1172#endif
5ed8fafc 1173
b250f9c6 1174#if CONFIG_ROQ_MUXER
76d32428
DB
1175AVOutputFormat roq_muxer =
1176{
1177 "RoQ",
b4ee1d39 1178 NULL_IF_CONFIG_SMALL("raw id RoQ format"),
76d32428
DB
1179 NULL,
1180 "roq",
1181 0,
1182 CODEC_ID_ROQ_DPCM,
1183 CODEC_ID_ROQ,
1184 roq_write_header,
1185 raw_write_packet,
1186};
082f7acf 1187#endif
76d32428 1188
b250f9c6 1189#if CONFIG_SHORTEN_DEMUXER
76d32428
DB
1190AVInputFormat shorten_demuxer = {
1191 "shn",
1192 NULL_IF_CONFIG_SMALL("raw Shorten"),
1193 0,
1194 NULL,
1195 audio_read_header,
81f052cb 1196 ff_raw_read_partial_packet,
76d32428
DB
1197 .flags= AVFMT_GENERIC_INDEX,
1198 .extensions = "shn",
1199 .value = CODEC_ID_SHORTEN,
1200};
7402ee23 1201#endif
76d32428 1202
b250f9c6 1203#if CONFIG_VC1_DEMUXER
7bb5c2a6
KS
1204AVInputFormat vc1_demuxer = {
1205 "vc1",
bde15e74 1206 NULL_IF_CONFIG_SMALL("raw VC-1"),
7bb5c2a6
KS
1207 0,
1208 NULL /* vc1_probe */,
1209 video_read_header,
81f052cb 1210 ff_raw_read_partial_packet,
7bb5c2a6
KS
1211 .extensions = "vc1",
1212 .value = CODEC_ID_VC1,
1213};
7402ee23 1214#endif
7bb5c2a6 1215
fb9f1117 1216/* PCM formats */
764ef400 1217
4986a429 1218#define PCMINPUTDEF(name, long_name, ext, codec) \
d2a067d1 1219AVInputFormat pcm_ ## name ## _demuxer = {\
764ef400 1220 #name,\
bde15e74 1221 NULL_IF_CONFIG_SMALL(long_name),\
764ef400
MM
1222 0,\
1223 NULL,\
1224 raw_read_header,\
1225 raw_read_packet,\
9b64a036 1226 NULL,\
4986a429 1227 pcm_read_seek,\
e9b78eeb 1228 .flags= AVFMT_GENERIC_INDEX,\
764ef400
MM
1229 .extensions = ext,\
1230 .value = codec,\
1231};
1232
2c8e2014 1233#define PCMOUTPUTDEF(name, long_name, ext, codec) \
d2a067d1 1234AVOutputFormat pcm_ ## name ## _muxer = {\
c9a65ca8 1235 #name,\
bde15e74 1236 NULL_IF_CONFIG_SMALL(long_name),\
c9a65ca8
FB
1237 NULL,\
1238 ext,\
1239 0,\
1240 codec,\
d9133126 1241 CODEC_ID_NONE,\
7a97dd84 1242 NULL,\
c9a65ca8 1243 raw_write_packet,\
494bbf58 1244 .flags= AVFMT_NOTIMESTAMPS,\
5ed8fafc 1245};
2c8e2014
DB
1246
1247
b250f9c6 1248#if !CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
1249#define PCMDEF(name, long_name, ext, codec) \
1250 PCMINPUTDEF(name, long_name, ext, codec)
b250f9c6 1251#elif CONFIG_MUXERS && !CONFIG_DEMUXERS
2c8e2014
DB
1252#define PCMDEF(name, long_name, ext, codec) \
1253 PCMOUTPUTDEF(name, long_name, ext, codec)
b250f9c6 1254#elif CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
1255#define PCMDEF(name, long_name, ext, codec) \
1256 PCMINPUTDEF(name, long_name, ext, codec)\
1257 PCMOUTPUTDEF(name, long_name, ext, codec)
1258#else
1259#define PCMDEF(name, long_name, ext, codec)
1260#endif
5ed8fafc 1261
63613fe6 1262#if HAVE_BIGENDIAN
c9a65ca8
FB
1263#define BE_DEF(s) s
1264#define LE_DEF(s) NULL
5ed8fafc 1265#else
c9a65ca8
FB
1266#define BE_DEF(s) NULL
1267#define LE_DEF(s) s
5ed8fafc 1268#endif
5ed8fafc 1269
ee7948cb
PR
1270PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
1271 NULL, CODEC_ID_PCM_F64BE)
1272
1273PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
1274 NULL, CODEC_ID_PCM_F64LE)
1275
1276PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
1277 NULL, CODEC_ID_PCM_F32BE)
1278
1279PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
1280 NULL, CODEC_ID_PCM_F32LE)
1281
1282PCMDEF(s32be, "PCM signed 32 bit big-endian format",
1283 NULL, CODEC_ID_PCM_S32BE)
1284
1285PCMDEF(s32le, "PCM signed 32 bit little-endian format",
1286 NULL, CODEC_ID_PCM_S32LE)
1287
1288PCMDEF(s24be, "PCM signed 24 bit big-endian format",
1289 NULL, CODEC_ID_PCM_S24BE)
1290
1291PCMDEF(s24le, "PCM signed 24 bit little-endian format",
1292 NULL, CODEC_ID_PCM_S24LE)
5ed8fafc 1293
ac1ea66e 1294PCMDEF(s16be, "PCM signed 16 bit big-endian format",
c9a65ca8 1295 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 1296
76d32428
DB
1297PCMDEF(s16le, "PCM signed 16 bit little-endian format",
1298 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
1299
1300PCMDEF(s8, "PCM signed 8 bit format",
1301 "sb", CODEC_ID_PCM_S8)
5ed8fafc 1302
ee7948cb
PR
1303PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
1304 NULL, CODEC_ID_PCM_U32BE)
1305
1306PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
1307 NULL, CODEC_ID_PCM_U32LE)
1308
1309PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
1310 NULL, CODEC_ID_PCM_U24BE)
1311
1312PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
1313 NULL, CODEC_ID_PCM_U24LE)
1314
ac1ea66e 1315PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
c9a65ca8 1316 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 1317
76d32428
DB
1318PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
1319 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 1320
ac1ea66e 1321PCMDEF(u8, "PCM unsigned 8 bit format",
c9a65ca8 1322 "ub", CODEC_ID_PCM_U8)
5ed8fafc 1323
ac1ea66e 1324PCMDEF(alaw, "PCM A-law format",
c9a65ca8 1325 "al", CODEC_ID_PCM_ALAW)
de6d9b64 1326
76d32428
DB
1327PCMDEF(mulaw, "PCM mu-law format",
1328 "ul", CODEC_ID_PCM_MULAW)