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