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