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