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