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