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