4261a6c9d1fa40ec6fd3f446adccefd79f688ff1
[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_NULL_MUXER
35 static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
36 {
37 return 0;
38 }
39 #endif
40
41 #if CONFIG_MUXERS
42 int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
43 {
44 put_buffer(s->pb, pkt->data, pkt->size);
45 put_flush_packet(s->pb);
46 return 0;
47 }
48 #endif
49
50 #if CONFIG_DEMUXERS
51 /* raw input */
52 static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
53 {
54 AVStream *st;
55 enum CodecID id;
56
57 st = av_new_stream(s, 0);
58 if (!st)
59 return AVERROR(ENOMEM);
60
61 id = s->iformat->value;
62 if (id == CODEC_ID_RAWVIDEO) {
63 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
64 } else {
65 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
66 }
67 st->codec->codec_id = id;
68
69 switch(st->codec->codec_type) {
70 case AVMEDIA_TYPE_AUDIO:
71 st->codec->sample_rate = ap->sample_rate;
72 if(ap->channels) st->codec->channels = ap->channels;
73 else st->codec->channels = 1;
74 st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
75 assert(st->codec->bits_per_coded_sample > 0);
76 st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
77 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
78 break;
79 case AVMEDIA_TYPE_VIDEO:
80 if(ap->time_base.num)
81 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
82 else
83 av_set_pts_info(st, 64, 1, 25);
84 st->codec->width = ap->width;
85 st->codec->height = ap->height;
86 st->codec->pix_fmt = ap->pix_fmt;
87 if(st->codec->pix_fmt == PIX_FMT_NONE)
88 st->codec->pix_fmt= PIX_FMT_YUV420P;
89 break;
90 default:
91 return -1;
92 }
93 return 0;
94 }
95
96 #define RAW_PACKET_SIZE 1024
97 #define RAW_SAMPLES 1024
98
99 static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
100 {
101 int ret, size, bps;
102 // AVStream *st = s->streams[0];
103
104 size= RAW_SAMPLES*s->streams[0]->codec->block_align;
105
106 ret= av_get_packet(s->pb, pkt, size);
107
108 pkt->stream_index = 0;
109 if (ret < 0)
110 return ret;
111
112 bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
113 assert(bps); // if false there IS a bug elsewhere (NOT in this function)
114 pkt->dts=
115 pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
116
117 return ret;
118 }
119
120 int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
121 {
122 int ret, size;
123
124 size = RAW_PACKET_SIZE;
125
126 if (av_new_packet(pkt, size) < 0)
127 return AVERROR(ENOMEM);
128
129 pkt->pos= url_ftell(s->pb);
130 pkt->stream_index = 0;
131 ret = get_partial_buffer(s->pb, pkt->data, size);
132 if (ret < 0) {
133 av_free_packet(pkt);
134 return ret;
135 }
136 pkt->size = ret;
137 return ret;
138 }
139 #endif
140
141 #if CONFIG_RAWVIDEO_DEMUXER
142 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
143 {
144 int packet_size, ret, width, height;
145 AVStream *st = s->streams[0];
146
147 width = st->codec->width;
148 height = st->codec->height;
149
150 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
151 if (packet_size < 0)
152 return -1;
153
154 ret= av_get_packet(s->pb, pkt, packet_size);
155 pkt->pts=
156 pkt->dts= pkt->pos / packet_size;
157
158 pkt->stream_index = 0;
159 if (ret < 0)
160 return ret;
161 return 0;
162 }
163 #endif
164
165 #if CONFIG_DEMUXERS
166 int pcm_read_seek(AVFormatContext *s,
167 int stream_index, int64_t timestamp, int flags)
168 {
169 AVStream *st;
170 int block_align, byte_rate;
171 int64_t pos, ret;
172
173 st = s->streams[0];
174
175 block_align = st->codec->block_align ? st->codec->block_align :
176 (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
177 byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
178 block_align * st->codec->sample_rate;
179
180 if (block_align <= 0 || byte_rate <= 0)
181 return -1;
182 if (timestamp < 0) timestamp = 0;
183
184 /* compute the position by aligning it to block_align */
185 pos = av_rescale_rnd(timestamp * byte_rate,
186 st->time_base.num,
187 st->time_base.den * (int64_t)block_align,
188 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
189 pos *= block_align;
190
191 /* recompute exact position */
192 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
193 if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
194 return ret;
195 return 0;
196 }
197
198 int ff_raw_audio_read_header(AVFormatContext *s,
199 AVFormatParameters *ap)
200 {
201 AVStream *st = av_new_stream(s, 0);
202 if (!st)
203 return AVERROR(ENOMEM);
204 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
205 st->codec->codec_id = s->iformat->value;
206 st->need_parsing = AVSTREAM_PARSE_FULL;
207 /* the parameters will be extracted from the compressed bitstream */
208
209 return 0;
210 }
211
212 /* MPEG-1/H.263 input */
213 int ff_raw_video_read_header(AVFormatContext *s,
214 AVFormatParameters *ap)
215 {
216 AVStream *st;
217
218 st = av_new_stream(s, 0);
219 if (!st)
220 return AVERROR(ENOMEM);
221
222 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
223 st->codec->codec_id = s->iformat->value;
224 st->need_parsing = AVSTREAM_PARSE_FULL;
225
226 /* for MJPEG, specify frame rate */
227 /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
228 if (ap->time_base.num) {
229 st->codec->time_base= ap->time_base;
230 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
231 st->codec->codec_id == CODEC_ID_MPEG4 ||
232 st->codec->codec_id == CODEC_ID_DIRAC ||
233 st->codec->codec_id == CODEC_ID_DNXHD ||
234 st->codec->codec_id == CODEC_ID_VC1 ||
235 st->codec->codec_id == CODEC_ID_H264) {
236 st->codec->time_base= (AVRational){1,25};
237 }
238 av_set_pts_info(st, 64, 1, 1200000);
239
240 return 0;
241 }
242 #endif
243
244 #if CONFIG_H263_DEMUXER
245 static int h263_probe(AVProbeData *p)
246 {
247 uint64_t code= -1;
248 int i;
249 int valid_psc=0;
250 int invalid_psc=0;
251 int res_change=0;
252 int src_fmt, last_src_fmt=-1;
253 int last_gn=0;
254
255 for(i=0; i<p->buf_size; i++){
256 code = (code<<8) + p->buf[i];
257 if ((code & 0xfffffc0000) == 0x800000) {
258 src_fmt= (code>>2)&3;
259 if( src_fmt != last_src_fmt
260 && last_src_fmt>0 && last_src_fmt<6
261 && src_fmt<6)
262 res_change++;
263
264 if((code&0x300)==0x200 && src_fmt){
265 valid_psc++;
266 last_gn=0;
267 }else
268 invalid_psc++;
269 last_src_fmt= src_fmt;
270 } else if((code & 0xffff800000) == 0x800000) {
271 int gn= (code>>(23-5)) & 0x1F;
272 if(gn<last_gn){
273 invalid_psc++;
274 }else
275 last_gn= gn;
276 }
277 }
278 //av_log(NULL, AV_LOG_ERROR, "h263_probe: psc:%d invalid:%d res_change:%d\n", valid_psc, invalid_psc, res_change);
279 //h263_probe: psc:3 invalid:0 res_change:0 (1588/recent_ffmpeg_parses_mpg_incorrectly.mpg)
280 if(valid_psc > 2*invalid_psc + 2*res_change + 3){
281 return 50;
282 }else if(valid_psc > 2*invalid_psc)
283 return 25;
284 return 0;
285 }
286 #endif
287
288 #if CONFIG_H261_DEMUXER
289 static int h261_probe(AVProbeData *p)
290 {
291 uint32_t code= -1;
292 int i;
293 int valid_psc=0;
294 int invalid_psc=0;
295 int next_gn=0;
296 int src_fmt=0;
297 GetBitContext gb;
298
299 init_get_bits(&gb, p->buf, p->buf_size*8);
300
301 for(i=0; i<p->buf_size*8; i++){
302 if ((code & 0x01ff0000) || !(code & 0xff00)) {
303 code = (code<<8) + get_bits(&gb, 8);
304 i += 7;
305 } else
306 code = (code<<1) + get_bits1(&gb);
307 if ((code & 0xffff0000) == 0x10000) {
308 int gn= (code>>12)&0xf;
309 if(!gn)
310 src_fmt= code&8;
311 if(gn != next_gn) invalid_psc++;
312 else valid_psc++;
313
314 if(src_fmt){ // CIF
315 next_gn= (gn+1 )%13;
316 }else{ //QCIF
317 next_gn= (gn+1+!!gn)% 7;
318 }
319 }
320 }
321 if(valid_psc > 2*invalid_psc + 6){
322 return 50;
323 }else if(valid_psc > 2*invalid_psc + 2)
324 return 25;
325 return 0;
326 }
327 #endif
328
329 #if CONFIG_DIRAC_DEMUXER
330 static int dirac_probe(AVProbeData *p)
331 {
332 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
333 return AVPROBE_SCORE_MAX;
334 else
335 return 0;
336 }
337 #endif
338
339 #if CONFIG_DNXHD_DEMUXER
340 static int dnxhd_probe(AVProbeData *p)
341 {
342 static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
343 int w, h, compression_id;
344 if (p->buf_size < 0x2c)
345 return 0;
346 if (memcmp(p->buf, header, 5))
347 return 0;
348 h = AV_RB16(p->buf + 0x18);
349 w = AV_RB16(p->buf + 0x1a);
350 if (!w || !h)
351 return 0;
352 compression_id = AV_RB32(p->buf + 0x28);
353 if (compression_id < 1237 || compression_id > 1253)
354 return 0;
355 return AVPROBE_SCORE_MAX;
356 }
357 #endif
358
359 #if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
360 static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
361 {
362 int max_frames, first_frames = 0, frames;
363 uint8_t *buf, *buf2, *end;
364 AC3HeaderInfo hdr;
365 GetBitContext gbc;
366 enum CodecID codec_id = CODEC_ID_AC3;
367
368 max_frames = 0;
369 buf = p->buf;
370 end = buf + p->buf_size;
371
372 for(; buf < end; buf++) {
373 buf2 = buf;
374
375 for(frames = 0; buf2 < end; frames++) {
376 init_get_bits(&gbc, buf2, 54);
377 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
378 break;
379 if(buf2 + hdr.frame_size > end ||
380 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
381 break;
382 if (hdr.bitstream_id > 10)
383 codec_id = CODEC_ID_EAC3;
384 buf2 += hdr.frame_size;
385 }
386 max_frames = FFMAX(max_frames, frames);
387 if(buf == p->buf)
388 first_frames = frames;
389 }
390 if(codec_id != expected_codec_id) return 0;
391 // keep this in sync with mp3 probe, both need to avoid
392 // issues with MPEG-files!
393 if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
394 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
395 else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
396 else if(max_frames>=1) return 1;
397 else return 0;
398 }
399 #endif
400
401 #if CONFIG_AC3_DEMUXER
402 static int ac3_probe(AVProbeData *p)
403 {
404 return ac3_eac3_probe(p, CODEC_ID_AC3);
405 }
406 #endif
407
408 #if CONFIG_EAC3_DEMUXER
409 static int eac3_probe(AVProbeData *p)
410 {
411 return ac3_eac3_probe(p, CODEC_ID_EAC3);
412 }
413 #endif
414
415 /* Note: Do not forget to add new entries to the Makefile as well. */
416
417 #if CONFIG_AC3_DEMUXER
418 AVInputFormat ac3_demuxer = {
419 "ac3",
420 NULL_IF_CONFIG_SMALL("raw AC-3"),
421 0,
422 ac3_probe,
423 ff_raw_audio_read_header,
424 ff_raw_read_partial_packet,
425 .flags= AVFMT_GENERIC_INDEX,
426 .extensions = "ac3",
427 .value = CODEC_ID_AC3,
428 };
429 #endif
430
431 #if CONFIG_AC3_MUXER
432 AVOutputFormat ac3_muxer = {
433 "ac3",
434 NULL_IF_CONFIG_SMALL("raw AC-3"),
435 "audio/x-ac3",
436 "ac3",
437 0,
438 CODEC_ID_AC3,
439 CODEC_ID_NONE,
440 NULL,
441 ff_raw_write_packet,
442 .flags= AVFMT_NOTIMESTAMPS,
443 };
444 #endif
445
446 #if CONFIG_DIRAC_DEMUXER
447 AVInputFormat dirac_demuxer = {
448 "dirac",
449 NULL_IF_CONFIG_SMALL("raw Dirac"),
450 0,
451 dirac_probe,
452 ff_raw_video_read_header,
453 ff_raw_read_partial_packet,
454 .flags= AVFMT_GENERIC_INDEX,
455 .value = CODEC_ID_DIRAC,
456 };
457 #endif
458
459 #if CONFIG_DIRAC_MUXER
460 AVOutputFormat dirac_muxer = {
461 "dirac",
462 NULL_IF_CONFIG_SMALL("raw Dirac"),
463 NULL,
464 "drc",
465 0,
466 CODEC_ID_NONE,
467 CODEC_ID_DIRAC,
468 NULL,
469 ff_raw_write_packet,
470 .flags= AVFMT_NOTIMESTAMPS,
471 };
472 #endif
473
474 #if CONFIG_DNXHD_DEMUXER
475 AVInputFormat dnxhd_demuxer = {
476 "dnxhd",
477 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
478 0,
479 dnxhd_probe,
480 ff_raw_video_read_header,
481 ff_raw_read_partial_packet,
482 .flags= AVFMT_GENERIC_INDEX,
483 .value = CODEC_ID_DNXHD,
484 };
485 #endif
486
487 #if CONFIG_DNXHD_MUXER
488 AVOutputFormat dnxhd_muxer = {
489 "dnxhd",
490 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
491 NULL,
492 "dnxhd",
493 0,
494 CODEC_ID_NONE,
495 CODEC_ID_DNXHD,
496 NULL,
497 ff_raw_write_packet,
498 .flags= AVFMT_NOTIMESTAMPS,
499 };
500 #endif
501
502 #if CONFIG_DTS_MUXER
503 AVOutputFormat dts_muxer = {
504 "dts",
505 NULL_IF_CONFIG_SMALL("raw DTS"),
506 "audio/x-dca",
507 "dts",
508 0,
509 CODEC_ID_DTS,
510 CODEC_ID_NONE,
511 NULL,
512 ff_raw_write_packet,
513 .flags= AVFMT_NOTIMESTAMPS,
514 };
515 #endif
516
517 #if CONFIG_EAC3_DEMUXER
518 AVInputFormat eac3_demuxer = {
519 "eac3",
520 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
521 0,
522 eac3_probe,
523 ff_raw_audio_read_header,
524 ff_raw_read_partial_packet,
525 .flags= AVFMT_GENERIC_INDEX,
526 .extensions = "eac3",
527 .value = CODEC_ID_EAC3,
528 };
529 #endif
530
531 #if CONFIG_EAC3_MUXER
532 AVOutputFormat eac3_muxer = {
533 "eac3",
534 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
535 "audio/x-eac3",
536 "eac3",
537 0,
538 CODEC_ID_EAC3,
539 CODEC_ID_NONE,
540 NULL,
541 ff_raw_write_packet,
542 .flags= AVFMT_NOTIMESTAMPS,
543 };
544 #endif
545
546 #if CONFIG_GSM_DEMUXER
547 AVInputFormat gsm_demuxer = {
548 "gsm",
549 NULL_IF_CONFIG_SMALL("raw GSM"),
550 0,
551 NULL,
552 ff_raw_audio_read_header,
553 ff_raw_read_partial_packet,
554 .flags= AVFMT_GENERIC_INDEX,
555 .extensions = "gsm",
556 .value = CODEC_ID_GSM,
557 };
558 #endif
559
560 #if CONFIG_H261_DEMUXER
561 AVInputFormat h261_demuxer = {
562 "h261",
563 NULL_IF_CONFIG_SMALL("raw H.261"),
564 0,
565 h261_probe,
566 ff_raw_video_read_header,
567 ff_raw_read_partial_packet,
568 .flags= AVFMT_GENERIC_INDEX,
569 .extensions = "h261",
570 .value = CODEC_ID_H261,
571 };
572 #endif
573
574 #if CONFIG_H261_MUXER
575 AVOutputFormat h261_muxer = {
576 "h261",
577 NULL_IF_CONFIG_SMALL("raw H.261"),
578 "video/x-h261",
579 "h261",
580 0,
581 CODEC_ID_NONE,
582 CODEC_ID_H261,
583 NULL,
584 ff_raw_write_packet,
585 .flags= AVFMT_NOTIMESTAMPS,
586 };
587 #endif
588
589 #if CONFIG_H263_DEMUXER
590 AVInputFormat h263_demuxer = {
591 "h263",
592 NULL_IF_CONFIG_SMALL("raw H.263"),
593 0,
594 h263_probe,
595 ff_raw_video_read_header,
596 ff_raw_read_partial_packet,
597 .flags= AVFMT_GENERIC_INDEX,
598 // .extensions = "h263", //FIXME remove after writing mpeg4_probe
599 .value = CODEC_ID_H263,
600 };
601 #endif
602
603 #if CONFIG_H263_MUXER
604 AVOutputFormat h263_muxer = {
605 "h263",
606 NULL_IF_CONFIG_SMALL("raw H.263"),
607 "video/x-h263",
608 "h263",
609 0,
610 CODEC_ID_NONE,
611 CODEC_ID_H263,
612 NULL,
613 ff_raw_write_packet,
614 .flags= AVFMT_NOTIMESTAMPS,
615 };
616 #endif
617
618 #if CONFIG_H264_MUXER
619 AVOutputFormat h264_muxer = {
620 "h264",
621 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
622 NULL,
623 "h264",
624 0,
625 CODEC_ID_NONE,
626 CODEC_ID_H264,
627 NULL,
628 ff_raw_write_packet,
629 .flags= AVFMT_NOTIMESTAMPS,
630 };
631 #endif
632
633 #if CONFIG_CAVSVIDEO_MUXER
634 AVOutputFormat cavsvideo_muxer = {
635 "cavsvideo",
636 NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
637 NULL,
638 "cavs",
639 0,
640 CODEC_ID_NONE,
641 CODEC_ID_CAVS,
642 NULL,
643 ff_raw_write_packet,
644 .flags= AVFMT_NOTIMESTAMPS,
645 };
646 #endif
647
648 #if CONFIG_M4V_MUXER
649 AVOutputFormat m4v_muxer = {
650 "m4v",
651 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
652 NULL,
653 "m4v",
654 0,
655 CODEC_ID_NONE,
656 CODEC_ID_MPEG4,
657 NULL,
658 ff_raw_write_packet,
659 .flags= AVFMT_NOTIMESTAMPS,
660 };
661 #endif
662
663 #if CONFIG_MJPEG_DEMUXER
664 AVInputFormat mjpeg_demuxer = {
665 "mjpeg",
666 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
667 0,
668 NULL,
669 ff_raw_video_read_header,
670 ff_raw_read_partial_packet,
671 .flags= AVFMT_GENERIC_INDEX,
672 .extensions = "mjpg,mjpeg",
673 .value = CODEC_ID_MJPEG,
674 };
675 #endif
676
677 #if CONFIG_MJPEG_MUXER
678 AVOutputFormat mjpeg_muxer = {
679 "mjpeg",
680 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
681 "video/x-mjpeg",
682 "mjpg,mjpeg",
683 0,
684 CODEC_ID_NONE,
685 CODEC_ID_MJPEG,
686 NULL,
687 ff_raw_write_packet,
688 .flags= AVFMT_NOTIMESTAMPS,
689 };
690 #endif
691
692 #if CONFIG_MLP_DEMUXER
693 AVInputFormat mlp_demuxer = {
694 "mlp",
695 NULL_IF_CONFIG_SMALL("raw MLP"),
696 0,
697 NULL,
698 ff_raw_audio_read_header,
699 ff_raw_read_partial_packet,
700 .flags= AVFMT_GENERIC_INDEX,
701 .extensions = "mlp",
702 .value = CODEC_ID_MLP,
703 };
704 #endif
705
706 #if CONFIG_MLP_MUXER
707 AVOutputFormat mlp_muxer = {
708 "mlp",
709 NULL_IF_CONFIG_SMALL("raw MLP"),
710 NULL,
711 "mlp",
712 0,
713 CODEC_ID_MLP,
714 CODEC_ID_NONE,
715 NULL,
716 ff_raw_write_packet,
717 .flags= AVFMT_NOTIMESTAMPS,
718 };
719 #endif
720
721 #if CONFIG_SRT_MUXER
722 AVOutputFormat srt_muxer = {
723 .name = "srt",
724 .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
725 .mime_type = "application/x-subrip",
726 .extensions = "srt",
727 .write_packet = ff_raw_write_packet,
728 .flags = AVFMT_NOTIMESTAMPS,
729 .subtitle_codec = CODEC_ID_SRT,
730 };
731 #endif
732
733 #if CONFIG_TRUEHD_DEMUXER
734 AVInputFormat truehd_demuxer = {
735 "truehd",
736 NULL_IF_CONFIG_SMALL("raw TrueHD"),
737 0,
738 NULL,
739 ff_raw_audio_read_header,
740 ff_raw_read_partial_packet,
741 .flags= AVFMT_GENERIC_INDEX,
742 .extensions = "thd",
743 .value = CODEC_ID_TRUEHD,
744 };
745 #endif
746
747 #if CONFIG_TRUEHD_MUXER
748 AVOutputFormat truehd_muxer = {
749 "truehd",
750 NULL_IF_CONFIG_SMALL("raw TrueHD"),
751 NULL,
752 "thd",
753 0,
754 CODEC_ID_TRUEHD,
755 CODEC_ID_NONE,
756 NULL,
757 ff_raw_write_packet,
758 .flags= AVFMT_NOTIMESTAMPS,
759 };
760 #endif
761
762 #if CONFIG_MPEG1VIDEO_MUXER
763 AVOutputFormat mpeg1video_muxer = {
764 "mpeg1video",
765 NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
766 "video/x-mpeg",
767 "mpg,mpeg,m1v",
768 0,
769 CODEC_ID_NONE,
770 CODEC_ID_MPEG1VIDEO,
771 NULL,
772 ff_raw_write_packet,
773 .flags= AVFMT_NOTIMESTAMPS,
774 };
775 #endif
776
777 #if CONFIG_MPEG2VIDEO_MUXER
778 AVOutputFormat mpeg2video_muxer = {
779 "mpeg2video",
780 NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
781 NULL,
782 "m2v",
783 0,
784 CODEC_ID_NONE,
785 CODEC_ID_MPEG2VIDEO,
786 NULL,
787 ff_raw_write_packet,
788 .flags= AVFMT_NOTIMESTAMPS,
789 };
790 #endif
791
792 #if CONFIG_NULL_MUXER
793 AVOutputFormat null_muxer = {
794 "null",
795 NULL_IF_CONFIG_SMALL("raw null video format"),
796 NULL,
797 NULL,
798 0,
799 AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
800 CODEC_ID_RAWVIDEO,
801 NULL,
802 null_write_packet,
803 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
804 };
805 #endif
806
807 #if CONFIG_RAWVIDEO_DEMUXER
808 AVInputFormat rawvideo_demuxer = {
809 "rawvideo",
810 NULL_IF_CONFIG_SMALL("raw video format"),
811 0,
812 NULL,
813 raw_read_header,
814 rawvideo_read_packet,
815 .flags= AVFMT_GENERIC_INDEX,
816 .extensions = "yuv,cif,qcif,rgb",
817 .value = CODEC_ID_RAWVIDEO,
818 };
819 #endif
820
821 #if CONFIG_RAWVIDEO_MUXER
822 AVOutputFormat rawvideo_muxer = {
823 "rawvideo",
824 NULL_IF_CONFIG_SMALL("raw video format"),
825 NULL,
826 "yuv,rgb",
827 0,
828 CODEC_ID_NONE,
829 CODEC_ID_RAWVIDEO,
830 NULL,
831 ff_raw_write_packet,
832 .flags= AVFMT_NOTIMESTAMPS,
833 };
834 #endif
835
836 #if CONFIG_SHORTEN_DEMUXER
837 AVInputFormat shorten_demuxer = {
838 "shn",
839 NULL_IF_CONFIG_SMALL("raw Shorten"),
840 0,
841 NULL,
842 ff_raw_audio_read_header,
843 ff_raw_read_partial_packet,
844 .flags= AVFMT_GENERIC_INDEX,
845 .extensions = "shn",
846 .value = CODEC_ID_SHORTEN,
847 };
848 #endif
849
850 #if CONFIG_VC1_DEMUXER
851 AVInputFormat vc1_demuxer = {
852 "vc1",
853 NULL_IF_CONFIG_SMALL("raw VC-1"),
854 0,
855 NULL /* vc1_probe */,
856 ff_raw_video_read_header,
857 ff_raw_read_partial_packet,
858 .extensions = "vc1",
859 .value = CODEC_ID_VC1,
860 };
861 #endif
862
863 /* PCM formats */
864
865 #define PCMINPUTDEF(name, long_name, ext, codec) \
866 AVInputFormat pcm_ ## name ## _demuxer = {\
867 #name,\
868 NULL_IF_CONFIG_SMALL(long_name),\
869 0,\
870 NULL,\
871 raw_read_header,\
872 raw_read_packet,\
873 NULL,\
874 pcm_read_seek,\
875 .flags= AVFMT_GENERIC_INDEX,\
876 .extensions = ext,\
877 .value = codec,\
878 };
879
880 #define PCMOUTPUTDEF(name, long_name, ext, codec) \
881 AVOutputFormat pcm_ ## name ## _muxer = {\
882 #name,\
883 NULL_IF_CONFIG_SMALL(long_name),\
884 NULL,\
885 ext,\
886 0,\
887 codec,\
888 CODEC_ID_NONE,\
889 NULL,\
890 ff_raw_write_packet,\
891 .flags= AVFMT_NOTIMESTAMPS,\
892 };
893
894
895 #if !CONFIG_MUXERS && CONFIG_DEMUXERS
896 #define PCMDEF(name, long_name, ext, codec) \
897 PCMINPUTDEF(name, long_name, ext, codec)
898 #elif CONFIG_MUXERS && !CONFIG_DEMUXERS
899 #define PCMDEF(name, long_name, ext, codec) \
900 PCMOUTPUTDEF(name, long_name, ext, codec)
901 #elif CONFIG_MUXERS && CONFIG_DEMUXERS
902 #define PCMDEF(name, long_name, ext, codec) \
903 PCMINPUTDEF(name, long_name, ext, codec)\
904 PCMOUTPUTDEF(name, long_name, ext, codec)
905 #else
906 #define PCMDEF(name, long_name, ext, codec)
907 #endif
908
909 #if HAVE_BIGENDIAN
910 #define BE_DEF(s) s
911 #define LE_DEF(s) NULL
912 #else
913 #define BE_DEF(s) NULL
914 #define LE_DEF(s) s
915 #endif
916
917 PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
918 NULL, CODEC_ID_PCM_F64BE)
919
920 PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
921 NULL, CODEC_ID_PCM_F64LE)
922
923 PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
924 NULL, CODEC_ID_PCM_F32BE)
925
926 PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
927 NULL, CODEC_ID_PCM_F32LE)
928
929 PCMDEF(s32be, "PCM signed 32 bit big-endian format",
930 NULL, CODEC_ID_PCM_S32BE)
931
932 PCMDEF(s32le, "PCM signed 32 bit little-endian format",
933 NULL, CODEC_ID_PCM_S32LE)
934
935 PCMDEF(s24be, "PCM signed 24 bit big-endian format",
936 NULL, CODEC_ID_PCM_S24BE)
937
938 PCMDEF(s24le, "PCM signed 24 bit little-endian format",
939 NULL, CODEC_ID_PCM_S24LE)
940
941 PCMDEF(s16be, "PCM signed 16 bit big-endian format",
942 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
943
944 PCMDEF(s16le, "PCM signed 16 bit little-endian format",
945 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
946
947 PCMDEF(s8, "PCM signed 8 bit format",
948 "sb", CODEC_ID_PCM_S8)
949
950 PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
951 NULL, CODEC_ID_PCM_U32BE)
952
953 PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
954 NULL, CODEC_ID_PCM_U32LE)
955
956 PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
957 NULL, CODEC_ID_PCM_U24BE)
958
959 PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
960 NULL, CODEC_ID_PCM_U24LE)
961
962 PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
963 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
964
965 PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
966 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
967
968 PCMDEF(u8, "PCM unsigned 8 bit format",
969 "ub", CODEC_ID_PCM_U8)
970
971 PCMDEF(alaw, "PCM A-law format",
972 "al", CODEC_ID_PCM_ALAW)
973
974 PCMDEF(mulaw, "PCM mu-law format",
975 "ul", CODEC_ID_PCM_MULAW)