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