move h263 demuxer to its own file
[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_H261_DEMUXER
245 static int h261_probe(AVProbeData *p)
246 {
247 uint32_t code= -1;
248 int i;
249 int valid_psc=0;
250 int invalid_psc=0;
251 int next_gn=0;
252 int src_fmt=0;
253 GetBitContext gb;
254
255 init_get_bits(&gb, p->buf, p->buf_size*8);
256
257 for(i=0; i<p->buf_size*8; i++){
258 if ((code & 0x01ff0000) || !(code & 0xff00)) {
259 code = (code<<8) + get_bits(&gb, 8);
260 i += 7;
261 } else
262 code = (code<<1) + get_bits1(&gb);
263 if ((code & 0xffff0000) == 0x10000) {
264 int gn= (code>>12)&0xf;
265 if(!gn)
266 src_fmt= code&8;
267 if(gn != next_gn) invalid_psc++;
268 else valid_psc++;
269
270 if(src_fmt){ // CIF
271 next_gn= (gn+1 )%13;
272 }else{ //QCIF
273 next_gn= (gn+1+!!gn)% 7;
274 }
275 }
276 }
277 if(valid_psc > 2*invalid_psc + 6){
278 return 50;
279 }else if(valid_psc > 2*invalid_psc + 2)
280 return 25;
281 return 0;
282 }
283 #endif
284
285 #if CONFIG_DIRAC_DEMUXER
286 static int dirac_probe(AVProbeData *p)
287 {
288 if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
289 return AVPROBE_SCORE_MAX;
290 else
291 return 0;
292 }
293 #endif
294
295 #if CONFIG_DNXHD_DEMUXER
296 static int dnxhd_probe(AVProbeData *p)
297 {
298 static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
299 int w, h, compression_id;
300 if (p->buf_size < 0x2c)
301 return 0;
302 if (memcmp(p->buf, header, 5))
303 return 0;
304 h = AV_RB16(p->buf + 0x18);
305 w = AV_RB16(p->buf + 0x1a);
306 if (!w || !h)
307 return 0;
308 compression_id = AV_RB32(p->buf + 0x28);
309 if (compression_id < 1237 || compression_id > 1253)
310 return 0;
311 return AVPROBE_SCORE_MAX;
312 }
313 #endif
314
315 #if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
316 static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
317 {
318 int max_frames, first_frames = 0, frames;
319 uint8_t *buf, *buf2, *end;
320 AC3HeaderInfo hdr;
321 GetBitContext gbc;
322 enum CodecID codec_id = CODEC_ID_AC3;
323
324 max_frames = 0;
325 buf = p->buf;
326 end = buf + p->buf_size;
327
328 for(; buf < end; buf++) {
329 buf2 = buf;
330
331 for(frames = 0; buf2 < end; frames++) {
332 init_get_bits(&gbc, buf2, 54);
333 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
334 break;
335 if(buf2 + hdr.frame_size > end ||
336 av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
337 break;
338 if (hdr.bitstream_id > 10)
339 codec_id = CODEC_ID_EAC3;
340 buf2 += hdr.frame_size;
341 }
342 max_frames = FFMAX(max_frames, frames);
343 if(buf == p->buf)
344 first_frames = frames;
345 }
346 if(codec_id != expected_codec_id) return 0;
347 // keep this in sync with mp3 probe, both need to avoid
348 // issues with MPEG-files!
349 if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
350 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
351 else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
352 else if(max_frames>=1) return 1;
353 else return 0;
354 }
355 #endif
356
357 #if CONFIG_AC3_DEMUXER
358 static int ac3_probe(AVProbeData *p)
359 {
360 return ac3_eac3_probe(p, CODEC_ID_AC3);
361 }
362 #endif
363
364 #if CONFIG_EAC3_DEMUXER
365 static int eac3_probe(AVProbeData *p)
366 {
367 return ac3_eac3_probe(p, CODEC_ID_EAC3);
368 }
369 #endif
370
371 /* Note: Do not forget to add new entries to the Makefile as well. */
372
373 #if CONFIG_AC3_DEMUXER
374 AVInputFormat ac3_demuxer = {
375 "ac3",
376 NULL_IF_CONFIG_SMALL("raw AC-3"),
377 0,
378 ac3_probe,
379 ff_raw_audio_read_header,
380 ff_raw_read_partial_packet,
381 .flags= AVFMT_GENERIC_INDEX,
382 .extensions = "ac3",
383 .value = CODEC_ID_AC3,
384 };
385 #endif
386
387 #if CONFIG_AC3_MUXER
388 AVOutputFormat ac3_muxer = {
389 "ac3",
390 NULL_IF_CONFIG_SMALL("raw AC-3"),
391 "audio/x-ac3",
392 "ac3",
393 0,
394 CODEC_ID_AC3,
395 CODEC_ID_NONE,
396 NULL,
397 ff_raw_write_packet,
398 .flags= AVFMT_NOTIMESTAMPS,
399 };
400 #endif
401
402 #if CONFIG_DIRAC_DEMUXER
403 AVInputFormat dirac_demuxer = {
404 "dirac",
405 NULL_IF_CONFIG_SMALL("raw Dirac"),
406 0,
407 dirac_probe,
408 ff_raw_video_read_header,
409 ff_raw_read_partial_packet,
410 .flags= AVFMT_GENERIC_INDEX,
411 .value = CODEC_ID_DIRAC,
412 };
413 #endif
414
415 #if CONFIG_DIRAC_MUXER
416 AVOutputFormat dirac_muxer = {
417 "dirac",
418 NULL_IF_CONFIG_SMALL("raw Dirac"),
419 NULL,
420 "drc",
421 0,
422 CODEC_ID_NONE,
423 CODEC_ID_DIRAC,
424 NULL,
425 ff_raw_write_packet,
426 .flags= AVFMT_NOTIMESTAMPS,
427 };
428 #endif
429
430 #if CONFIG_DNXHD_DEMUXER
431 AVInputFormat dnxhd_demuxer = {
432 "dnxhd",
433 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
434 0,
435 dnxhd_probe,
436 ff_raw_video_read_header,
437 ff_raw_read_partial_packet,
438 .flags= AVFMT_GENERIC_INDEX,
439 .value = CODEC_ID_DNXHD,
440 };
441 #endif
442
443 #if CONFIG_DNXHD_MUXER
444 AVOutputFormat dnxhd_muxer = {
445 "dnxhd",
446 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
447 NULL,
448 "dnxhd",
449 0,
450 CODEC_ID_NONE,
451 CODEC_ID_DNXHD,
452 NULL,
453 ff_raw_write_packet,
454 .flags= AVFMT_NOTIMESTAMPS,
455 };
456 #endif
457
458 #if CONFIG_DTS_MUXER
459 AVOutputFormat dts_muxer = {
460 "dts",
461 NULL_IF_CONFIG_SMALL("raw DTS"),
462 "audio/x-dca",
463 "dts",
464 0,
465 CODEC_ID_DTS,
466 CODEC_ID_NONE,
467 NULL,
468 ff_raw_write_packet,
469 .flags= AVFMT_NOTIMESTAMPS,
470 };
471 #endif
472
473 #if CONFIG_EAC3_DEMUXER
474 AVInputFormat eac3_demuxer = {
475 "eac3",
476 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
477 0,
478 eac3_probe,
479 ff_raw_audio_read_header,
480 ff_raw_read_partial_packet,
481 .flags= AVFMT_GENERIC_INDEX,
482 .extensions = "eac3",
483 .value = CODEC_ID_EAC3,
484 };
485 #endif
486
487 #if CONFIG_EAC3_MUXER
488 AVOutputFormat eac3_muxer = {
489 "eac3",
490 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
491 "audio/x-eac3",
492 "eac3",
493 0,
494 CODEC_ID_EAC3,
495 CODEC_ID_NONE,
496 NULL,
497 ff_raw_write_packet,
498 .flags= AVFMT_NOTIMESTAMPS,
499 };
500 #endif
501
502 #if CONFIG_GSM_DEMUXER
503 AVInputFormat gsm_demuxer = {
504 "gsm",
505 NULL_IF_CONFIG_SMALL("raw GSM"),
506 0,
507 NULL,
508 ff_raw_audio_read_header,
509 ff_raw_read_partial_packet,
510 .flags= AVFMT_GENERIC_INDEX,
511 .extensions = "gsm",
512 .value = CODEC_ID_GSM,
513 };
514 #endif
515
516 #if CONFIG_H261_DEMUXER
517 AVInputFormat h261_demuxer = {
518 "h261",
519 NULL_IF_CONFIG_SMALL("raw H.261"),
520 0,
521 h261_probe,
522 ff_raw_video_read_header,
523 ff_raw_read_partial_packet,
524 .flags= AVFMT_GENERIC_INDEX,
525 .extensions = "h261",
526 .value = CODEC_ID_H261,
527 };
528 #endif
529
530 #if CONFIG_H261_MUXER
531 AVOutputFormat h261_muxer = {
532 "h261",
533 NULL_IF_CONFIG_SMALL("raw H.261"),
534 "video/x-h261",
535 "h261",
536 0,
537 CODEC_ID_NONE,
538 CODEC_ID_H261,
539 NULL,
540 ff_raw_write_packet,
541 .flags= AVFMT_NOTIMESTAMPS,
542 };
543 #endif
544
545 #if CONFIG_H263_MUXER
546 AVOutputFormat h263_muxer = {
547 "h263",
548 NULL_IF_CONFIG_SMALL("raw H.263"),
549 "video/x-h263",
550 "h263",
551 0,
552 CODEC_ID_NONE,
553 CODEC_ID_H263,
554 NULL,
555 ff_raw_write_packet,
556 .flags= AVFMT_NOTIMESTAMPS,
557 };
558 #endif
559
560 #if CONFIG_H264_MUXER
561 AVOutputFormat h264_muxer = {
562 "h264",
563 NULL_IF_CONFIG_SMALL("raw H.264 video format"),
564 NULL,
565 "h264",
566 0,
567 CODEC_ID_NONE,
568 CODEC_ID_H264,
569 NULL,
570 ff_raw_write_packet,
571 .flags= AVFMT_NOTIMESTAMPS,
572 };
573 #endif
574
575 #if CONFIG_CAVSVIDEO_MUXER
576 AVOutputFormat cavsvideo_muxer = {
577 "cavsvideo",
578 NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
579 NULL,
580 "cavs",
581 0,
582 CODEC_ID_NONE,
583 CODEC_ID_CAVS,
584 NULL,
585 ff_raw_write_packet,
586 .flags= AVFMT_NOTIMESTAMPS,
587 };
588 #endif
589
590 #if CONFIG_M4V_MUXER
591 AVOutputFormat m4v_muxer = {
592 "m4v",
593 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
594 NULL,
595 "m4v",
596 0,
597 CODEC_ID_NONE,
598 CODEC_ID_MPEG4,
599 NULL,
600 ff_raw_write_packet,
601 .flags= AVFMT_NOTIMESTAMPS,
602 };
603 #endif
604
605 #if CONFIG_MJPEG_DEMUXER
606 AVInputFormat mjpeg_demuxer = {
607 "mjpeg",
608 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
609 0,
610 NULL,
611 ff_raw_video_read_header,
612 ff_raw_read_partial_packet,
613 .flags= AVFMT_GENERIC_INDEX,
614 .extensions = "mjpg,mjpeg",
615 .value = CODEC_ID_MJPEG,
616 };
617 #endif
618
619 #if CONFIG_MJPEG_MUXER
620 AVOutputFormat mjpeg_muxer = {
621 "mjpeg",
622 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
623 "video/x-mjpeg",
624 "mjpg,mjpeg",
625 0,
626 CODEC_ID_NONE,
627 CODEC_ID_MJPEG,
628 NULL,
629 ff_raw_write_packet,
630 .flags= AVFMT_NOTIMESTAMPS,
631 };
632 #endif
633
634 #if CONFIG_MLP_DEMUXER
635 AVInputFormat mlp_demuxer = {
636 "mlp",
637 NULL_IF_CONFIG_SMALL("raw MLP"),
638 0,
639 NULL,
640 ff_raw_audio_read_header,
641 ff_raw_read_partial_packet,
642 .flags= AVFMT_GENERIC_INDEX,
643 .extensions = "mlp",
644 .value = CODEC_ID_MLP,
645 };
646 #endif
647
648 #if CONFIG_MLP_MUXER
649 AVOutputFormat mlp_muxer = {
650 "mlp",
651 NULL_IF_CONFIG_SMALL("raw MLP"),
652 NULL,
653 "mlp",
654 0,
655 CODEC_ID_MLP,
656 CODEC_ID_NONE,
657 NULL,
658 ff_raw_write_packet,
659 .flags= AVFMT_NOTIMESTAMPS,
660 };
661 #endif
662
663 #if CONFIG_SRT_MUXER
664 AVOutputFormat srt_muxer = {
665 .name = "srt",
666 .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
667 .mime_type = "application/x-subrip",
668 .extensions = "srt",
669 .write_packet = ff_raw_write_packet,
670 .flags = AVFMT_NOTIMESTAMPS,
671 .subtitle_codec = CODEC_ID_SRT,
672 };
673 #endif
674
675 #if CONFIG_TRUEHD_DEMUXER
676 AVInputFormat truehd_demuxer = {
677 "truehd",
678 NULL_IF_CONFIG_SMALL("raw TrueHD"),
679 0,
680 NULL,
681 ff_raw_audio_read_header,
682 ff_raw_read_partial_packet,
683 .flags= AVFMT_GENERIC_INDEX,
684 .extensions = "thd",
685 .value = CODEC_ID_TRUEHD,
686 };
687 #endif
688
689 #if CONFIG_TRUEHD_MUXER
690 AVOutputFormat truehd_muxer = {
691 "truehd",
692 NULL_IF_CONFIG_SMALL("raw TrueHD"),
693 NULL,
694 "thd",
695 0,
696 CODEC_ID_TRUEHD,
697 CODEC_ID_NONE,
698 NULL,
699 ff_raw_write_packet,
700 .flags= AVFMT_NOTIMESTAMPS,
701 };
702 #endif
703
704 #if CONFIG_MPEG1VIDEO_MUXER
705 AVOutputFormat mpeg1video_muxer = {
706 "mpeg1video",
707 NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
708 "video/x-mpeg",
709 "mpg,mpeg,m1v",
710 0,
711 CODEC_ID_NONE,
712 CODEC_ID_MPEG1VIDEO,
713 NULL,
714 ff_raw_write_packet,
715 .flags= AVFMT_NOTIMESTAMPS,
716 };
717 #endif
718
719 #if CONFIG_MPEG2VIDEO_MUXER
720 AVOutputFormat mpeg2video_muxer = {
721 "mpeg2video",
722 NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
723 NULL,
724 "m2v",
725 0,
726 CODEC_ID_NONE,
727 CODEC_ID_MPEG2VIDEO,
728 NULL,
729 ff_raw_write_packet,
730 .flags= AVFMT_NOTIMESTAMPS,
731 };
732 #endif
733
734 #if CONFIG_NULL_MUXER
735 AVOutputFormat null_muxer = {
736 "null",
737 NULL_IF_CONFIG_SMALL("raw null video format"),
738 NULL,
739 NULL,
740 0,
741 AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
742 CODEC_ID_RAWVIDEO,
743 NULL,
744 null_write_packet,
745 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
746 };
747 #endif
748
749 #if CONFIG_RAWVIDEO_DEMUXER
750 AVInputFormat rawvideo_demuxer = {
751 "rawvideo",
752 NULL_IF_CONFIG_SMALL("raw video format"),
753 0,
754 NULL,
755 raw_read_header,
756 rawvideo_read_packet,
757 .flags= AVFMT_GENERIC_INDEX,
758 .extensions = "yuv,cif,qcif,rgb",
759 .value = CODEC_ID_RAWVIDEO,
760 };
761 #endif
762
763 #if CONFIG_RAWVIDEO_MUXER
764 AVOutputFormat rawvideo_muxer = {
765 "rawvideo",
766 NULL_IF_CONFIG_SMALL("raw video format"),
767 NULL,
768 "yuv,rgb",
769 0,
770 CODEC_ID_NONE,
771 CODEC_ID_RAWVIDEO,
772 NULL,
773 ff_raw_write_packet,
774 .flags= AVFMT_NOTIMESTAMPS,
775 };
776 #endif
777
778 #if CONFIG_SHORTEN_DEMUXER
779 AVInputFormat shorten_demuxer = {
780 "shn",
781 NULL_IF_CONFIG_SMALL("raw Shorten"),
782 0,
783 NULL,
784 ff_raw_audio_read_header,
785 ff_raw_read_partial_packet,
786 .flags= AVFMT_GENERIC_INDEX,
787 .extensions = "shn",
788 .value = CODEC_ID_SHORTEN,
789 };
790 #endif
791
792 #if CONFIG_VC1_DEMUXER
793 AVInputFormat vc1_demuxer = {
794 "vc1",
795 NULL_IF_CONFIG_SMALL("raw VC-1"),
796 0,
797 NULL /* vc1_probe */,
798 ff_raw_video_read_header,
799 ff_raw_read_partial_packet,
800 .extensions = "vc1",
801 .value = CODEC_ID_VC1,
802 };
803 #endif
804
805 /* PCM formats */
806
807 #define PCMINPUTDEF(name, long_name, ext, codec) \
808 AVInputFormat pcm_ ## name ## _demuxer = {\
809 #name,\
810 NULL_IF_CONFIG_SMALL(long_name),\
811 0,\
812 NULL,\
813 raw_read_header,\
814 raw_read_packet,\
815 NULL,\
816 pcm_read_seek,\
817 .flags= AVFMT_GENERIC_INDEX,\
818 .extensions = ext,\
819 .value = codec,\
820 };
821
822 #define PCMOUTPUTDEF(name, long_name, ext, codec) \
823 AVOutputFormat pcm_ ## name ## _muxer = {\
824 #name,\
825 NULL_IF_CONFIG_SMALL(long_name),\
826 NULL,\
827 ext,\
828 0,\
829 codec,\
830 CODEC_ID_NONE,\
831 NULL,\
832 ff_raw_write_packet,\
833 .flags= AVFMT_NOTIMESTAMPS,\
834 };
835
836
837 #if !CONFIG_MUXERS && CONFIG_DEMUXERS
838 #define PCMDEF(name, long_name, ext, codec) \
839 PCMINPUTDEF(name, long_name, ext, codec)
840 #elif CONFIG_MUXERS && !CONFIG_DEMUXERS
841 #define PCMDEF(name, long_name, ext, codec) \
842 PCMOUTPUTDEF(name, long_name, ext, codec)
843 #elif CONFIG_MUXERS && CONFIG_DEMUXERS
844 #define PCMDEF(name, long_name, ext, codec) \
845 PCMINPUTDEF(name, long_name, ext, codec)\
846 PCMOUTPUTDEF(name, long_name, ext, codec)
847 #else
848 #define PCMDEF(name, long_name, ext, codec)
849 #endif
850
851 #if HAVE_BIGENDIAN
852 #define BE_DEF(s) s
853 #define LE_DEF(s) NULL
854 #else
855 #define BE_DEF(s) NULL
856 #define LE_DEF(s) s
857 #endif
858
859 PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
860 NULL, CODEC_ID_PCM_F64BE)
861
862 PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
863 NULL, CODEC_ID_PCM_F64LE)
864
865 PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
866 NULL, CODEC_ID_PCM_F32BE)
867
868 PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
869 NULL, CODEC_ID_PCM_F32LE)
870
871 PCMDEF(s32be, "PCM signed 32 bit big-endian format",
872 NULL, CODEC_ID_PCM_S32BE)
873
874 PCMDEF(s32le, "PCM signed 32 bit little-endian format",
875 NULL, CODEC_ID_PCM_S32LE)
876
877 PCMDEF(s24be, "PCM signed 24 bit big-endian format",
878 NULL, CODEC_ID_PCM_S24BE)
879
880 PCMDEF(s24le, "PCM signed 24 bit little-endian format",
881 NULL, CODEC_ID_PCM_S24LE)
882
883 PCMDEF(s16be, "PCM signed 16 bit big-endian format",
884 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
885
886 PCMDEF(s16le, "PCM signed 16 bit little-endian format",
887 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
888
889 PCMDEF(s8, "PCM signed 8 bit format",
890 "sb", CODEC_ID_PCM_S8)
891
892 PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
893 NULL, CODEC_ID_PCM_U32BE)
894
895 PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
896 NULL, CODEC_ID_PCM_U32LE)
897
898 PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
899 NULL, CODEC_ID_PCM_U24BE)
900
901 PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
902 NULL, CODEC_ID_PCM_U24LE)
903
904 PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
905 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
906
907 PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
908 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
909
910 PCMDEF(u8, "PCM unsigned 8 bit format",
911 "ub", CODEC_ID_PCM_U8)
912
913 PCMDEF(alaw, "PCM A-law format",
914 "al", CODEC_ID_PCM_ALAW)
915
916 PCMDEF(mulaw, "PCM mu-law format",
917 "ul", CODEC_ID_PCM_MULAW)