move h263 demuxer to its own file
[libav.git] / libavformat / raw.c
CommitLineData
115329f1 1/*
7fbde343 2 * RAW muxer and demuxer
406792e7 3 * Copyright (c) 2001 Fabrice Bellard
84c63c01 4 * Copyright (c) 2005 Alex Beregszaszi
de6d9b64 5 *
b78e7197
DB
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
19720f15
FB
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
b78e7197 11 * version 2.1 of the License, or (at your option) any later version.
de6d9b64 12 *
b78e7197 13 * FFmpeg is distributed in the hope that it will be useful,
de6d9b64 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19720f15
FB
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
de6d9b64 17 *
19720f15 18 * You should have received a copy of the GNU Lesser General Public
b78e7197 19 * License along with FFmpeg; if not, write to the Free Software
5509bffa 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
de6d9b64 21 */
245976da
DB
22
23#include "libavutil/crc.h"
24#include "libavcodec/ac3_parser.h"
9106a698 25#include "libavcodec/get_bits.h"
245976da 26#include "libavcodec/bytestream.h"
de6d9b64 27#include "avformat.h"
7241a6bb 28#include "raw.h"
ac3ef4a4 29#include "id3v2.h"
d52b90bd 30#include "id3v1.h"
de6d9b64
FB
31
32/* simple formats */
ce1d2a95 33
b250f9c6 34#if CONFIG_NULL_MUXER
76d32428
DB
35static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
36{
37 return 0;
38}
96445426 39#endif
76d32428 40
b250f9c6 41#if CONFIG_MUXERS
54a73bb5 42int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 43{
899681cd
BA
44 put_buffer(s->pb, pkt->data, pkt->size);
45 put_flush_packet(s->pb);
de6d9b64
FB
46 return 0;
47}
082f7acf 48#endif
de6d9b64 49
b250f9c6 50#if CONFIG_DEMUXERS
de6d9b64 51/* raw input */
0c1a9eda 52static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
de6d9b64
FB
53{
54 AVStream *st;
0f87b771 55 enum CodecID id;
de6d9b64 56
c9a65ca8 57 st = av_new_stream(s, 0);
de6d9b64 58 if (!st)
769e10f0 59 return AVERROR(ENOMEM);
c04c3282 60
c9a65ca8
FB
61 id = s->iformat->value;
62 if (id == CODEC_ID_RAWVIDEO) {
72415b2a 63 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
de6d9b64 64 } else {
72415b2a 65 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
de6d9b64 66 }
01f4895c 67 st->codec->codec_id = id;
c9a65ca8 68
01f4895c 69 switch(st->codec->codec_type) {
72415b2a 70 case AVMEDIA_TYPE_AUDIO:
01f4895c 71 st->codec->sample_rate = ap->sample_rate;
bf9067cf
MN
72 if(ap->channels) st->codec->channels = ap->channels;
73 else st->codec->channels = 1;
a3d23e15
BC
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;
01f4895c 77 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
de6d9b64 78 break;
72415b2a 79 case AVMEDIA_TYPE_VIDEO:
9de0be61
MN
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);
01f4895c
MN
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;
de6d9b64
FB
89 break;
90 default:
27e084bd 91 return -1;
de6d9b64 92 }
de6d9b64
FB
93 return 0;
94}
95
2e93e3aa 96#define RAW_PACKET_SIZE 1024
a3d23e15 97#define RAW_SAMPLES 1024
de6d9b64 98
5c91a675 99static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 100{
f5b41031 101 int ret, size, bps;
2a6874fd 102 // AVStream *st = s->streams[0];
115329f1 103
a3d23e15 104 size= RAW_SAMPLES*s->streams[0]->codec->block_align;
de6d9b64 105
899681cd 106 ret= av_get_packet(s->pb, pkt, size);
de6d9b64
FB
107
108 pkt->stream_index = 0;
c3db0bc6
RD
109 if (ret < 0)
110 return ret;
f5b41031
MN
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
de6d9b64
FB
117 return ret;
118}
119
81f052cb 120int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
e15dec10
LS
121{
122 int ret, size;
123
124 size = RAW_PACKET_SIZE;
125
126 if (av_new_packet(pkt, size) < 0)
c67031e7 127 return AVERROR(ENOMEM);
115329f1 128
899681cd 129 pkt->pos= url_ftell(s->pb);
e15dec10 130 pkt->stream_index = 0;
899681cd 131 ret = get_partial_buffer(s->pb, pkt->data, size);
c3db0bc6 132 if (ret < 0) {
e15dec10 133 av_free_packet(pkt);
c3db0bc6 134 return ret;
e15dec10
LS
135 }
136 pkt->size = ret;
137 return ret;
138}
4c00864f 139#endif
e15dec10 140
b250f9c6 141#if CONFIG_RAWVIDEO_DEMUXER
76d32428
DB
142static 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;
c3db0bc6
RD
159 if (ret < 0)
160 return ret;
8cb724c5 161 return 0;
76d32428 162}
4c00864f 163#endif
76d32428 164
b250f9c6 165#if CONFIG_DEMUXERS
115329f1 166int pcm_read_seek(AVFormatContext *s,
7b3c1382 167 int stream_index, int64_t timestamp, int flags)
4986a429
FB
168{
169 AVStream *st;
79c07907
DV
170 int block_align, byte_rate;
171 int64_t pos, ret;
4986a429
FB
172
173 st = s->streams[0];
708e3e7d
BC
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;
115329f1 179
4986a429
FB
180 if (block_align <= 0 || byte_rate <= 0)
181 return -1;
bd36f175 182 if (timestamp < 0) timestamp = 0;
4986a429
FB
183
184 /* compute the position by aligning it to block_align */
115329f1
DB
185 pos = av_rescale_rnd(timestamp * byte_rate,
186 st->time_base.num,
7b3c1382
MN
187 st->time_base.den * (int64_t)block_align,
188 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
189 pos *= block_align;
4986a429
FB
190
191 /* recompute exact position */
77405fc8 192 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
d701934b
BC
193 if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
194 return ret;
4986a429
FB
195 return 0;
196}
197
6d0678d1 198int ff_raw_audio_read_header(AVFormatContext *s,
a0af2fa4 199 AVFormatParameters *ap)
fda885c7 200{
a0af2fa4 201 AVStream *st = av_new_stream(s, 0);
fda885c7 202 if (!st)
769e10f0 203 return AVERROR(ENOMEM);
72415b2a 204 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
a0af2fa4 205 st->codec->codec_id = s->iformat->value;
57004ff1 206 st->need_parsing = AVSTREAM_PARSE_FULL;
fda885c7 207 /* the parameters will be extracted from the compressed bitstream */
6cde949a 208
fda885c7
MR
209 return 0;
210}
211
fb9f1117 212/* MPEG-1/H.263 input */
b47a5a95 213int ff_raw_video_read_header(AVFormatContext *s,
de6d9b64
FB
214 AVFormatParameters *ap)
215{
216 AVStream *st;
217
c9a65ca8 218 st = av_new_stream(s, 0);
de6d9b64 219 if (!st)
769e10f0 220 return AVERROR(ENOMEM);
de6d9b64 221
72415b2a 222 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
01f4895c 223 st->codec->codec_id = s->iformat->value;
57004ff1 224 st->need_parsing = AVSTREAM_PARSE_FULL;
4986a429 225
fb9f1117
DB
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 ...)*/
c04c3282 228 if (ap->time_base.num) {
4022fe01 229 st->codec->time_base= ap->time_base;
115329f1 230 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
01f4895c 231 st->codec->codec_id == CODEC_ID_MPEG4 ||
17ac9f1c 232 st->codec->codec_id == CODEC_ID_DIRAC ||
0cd55b0c 233 st->codec->codec_id == CODEC_ID_DNXHD ||
1c169711 234 st->codec->codec_id == CODEC_ID_VC1 ||
01f4895c 235 st->codec->codec_id == CODEC_ID_H264) {
4022fe01 236 st->codec->time_base= (AVRational){1,25};
27e084bd 237 }
4022fe01 238 av_set_pts_info(st, 64, 1, 1200000);
80ce3254 239
de6d9b64
FB
240 return 0;
241}
4c00864f 242#endif
de6d9b64 243
b250f9c6 244#if CONFIG_H261_DEMUXER
c6148de2
MN
245static int h261_probe(AVProbeData *p)
246{
89c4e176
MN
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++){
3adcfbbe
RD
258 if ((code & 0x01ff0000) || !(code & 0xff00)) {
259 code = (code<<8) + get_bits(&gb, 8);
260 i += 7;
261 } else
4130f739 262 code = (code<<1) + get_bits1(&gb);
89c4e176
MN
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 }
c6148de2 276 }
2a3caca2 277 if(valid_psc > 2*invalid_psc + 6){
89c4e176
MN
278 return 50;
279 }else if(valid_psc > 2*invalid_psc + 2)
280 return 25;
c6148de2
MN
281 return 0;
282}
4c00864f 283#endif
c6148de2 284
b250f9c6 285#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
286static 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}
4c00864f 293#endif
17ac9f1c 294
b250f9c6 295#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
296static int dnxhd_probe(AVProbeData *p)
297{
298 static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
98487a5b
RD
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)
bd09e8a7 310 return 0;
98487a5b 311 return AVPROBE_SCORE_MAX;
bd09e8a7
BC
312}
313#endif
314
b250f9c6 315#if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
75198e7a 316static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
7156aeb9 317{
8c222bb4 318 int max_frames, first_frames = 0, frames;
f8b9830b
JR
319 uint8_t *buf, *buf2, *end;
320 AC3HeaderInfo hdr;
55736cfb 321 GetBitContext gbc;
75198e7a 322 enum CodecID codec_id = CODEC_ID_AC3;
7156aeb9 323
f8b9830b
JR
324 max_frames = 0;
325 buf = p->buf;
ecc8fc11 326 end = buf + p->buf_size;
f8b9830b
JR
327
328 for(; buf < end; buf++) {
329 buf2 = buf;
7156aeb9 330
f8b9830b 331 for(frames = 0; buf2 < end; frames++) {
55736cfb
BW
332 init_get_bits(&gbc, buf2, 54);
333 if(ff_ac3_parse_header(&gbc, &hdr) < 0)
f8b9830b 334 break;
c675ef70
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;
2988c93d 338 if (hdr.bitstream_id > 10)
75198e7a 339 codec_id = CODEC_ID_EAC3;
f8b9830b
JR
340 buf2 += hdr.frame_size;
341 }
342 max_frames = FFMAX(max_frames, frames);
343 if(buf == p->buf)
344 first_frames = frames;
345 }
75198e7a 346 if(codec_id != expected_codec_id) return 0;
4b4ac5c7
RD
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;
f8b9830b
JR
352 else if(max_frames>=1) return 1;
353 else return 0;
7156aeb9 354}
4c00864f 355#endif
7156aeb9 356
b250f9c6 357#if CONFIG_AC3_DEMUXER
2988c93d
JR
358static int ac3_probe(AVProbeData *p)
359{
75198e7a 360 return ac3_eac3_probe(p, CODEC_ID_AC3);
2988c93d
JR
361}
362#endif
363
b250f9c6 364#if CONFIG_EAC3_DEMUXER
2988c93d
JR
365static int eac3_probe(AVProbeData *p)
366{
75198e7a 367 return ac3_eac3_probe(p, CODEC_ID_EAC3);
2988c93d
JR
368}
369#endif
370
900eb63d
DB
371/* Note: Do not forget to add new entries to the Makefile as well. */
372
b250f9c6 373#if CONFIG_AC3_DEMUXER
d2a067d1 374AVInputFormat ac3_demuxer = {
c9a65ca8 375 "ac3",
bde15e74 376 NULL_IF_CONFIG_SMALL("raw AC-3"),
c9a65ca8 377 0,
7156aeb9 378 ac3_probe,
6d0678d1 379 ff_raw_audio_read_header,
81f052cb 380 ff_raw_read_partial_packet,
e9b78eeb 381 .flags= AVFMT_GENERIC_INDEX,
bb76a117 382 .extensions = "ac3",
a0af2fa4 383 .value = CODEC_ID_AC3,
de6d9b64 384};
cefd4907 385#endif
de6d9b64 386
b250f9c6 387#if CONFIG_AC3_MUXER
d2a067d1 388AVOutputFormat ac3_muxer = {
de6d9b64 389 "ac3",
bde15e74 390 NULL_IF_CONFIG_SMALL("raw AC-3"),
115329f1 391 "audio/x-ac3",
de6d9b64 392 "ac3",
c9a65ca8 393 0,
de6d9b64 394 CODEC_ID_AC3,
d9133126 395 CODEC_ID_NONE,
7a97dd84 396 NULL,
54a73bb5 397 ff_raw_write_packet,
494bbf58 398 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 399};
082f7acf 400#endif
de6d9b64 401
b250f9c6 402#if CONFIG_DIRAC_DEMUXER
17ac9f1c
LB
403AVInputFormat dirac_demuxer = {
404 "dirac",
bde15e74 405 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
406 0,
407 dirac_probe,
b47a5a95 408 ff_raw_video_read_header,
81f052cb 409 ff_raw_read_partial_packet,
17ac9f1c
LB
410 .flags= AVFMT_GENERIC_INDEX,
411 .value = CODEC_ID_DIRAC,
412};
7402ee23 413#endif
17ac9f1c 414
b250f9c6 415#if CONFIG_DIRAC_MUXER
17ac9f1c
LB
416AVOutputFormat dirac_muxer = {
417 "dirac",
bde15e74 418 NULL_IF_CONFIG_SMALL("raw Dirac"),
17ac9f1c
LB
419 NULL,
420 "drc",
421 0,
d9133126 422 CODEC_ID_NONE,
17ac9f1c
LB
423 CODEC_ID_DIRAC,
424 NULL,
54a73bb5 425 ff_raw_write_packet,
17ac9f1c
LB
426 .flags= AVFMT_NOTIMESTAMPS,
427};
428#endif
429
b250f9c6 430#if CONFIG_DNXHD_DEMUXER
bd09e8a7
BC
431AVInputFormat dnxhd_demuxer = {
432 "dnxhd",
433 NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
434 0,
435 dnxhd_probe,
b47a5a95 436 ff_raw_video_read_header,
81f052cb 437 ff_raw_read_partial_packet,
bd09e8a7
BC
438 .flags= AVFMT_GENERIC_INDEX,
439 .value = CODEC_ID_DNXHD,
440};
441#endif
442
b250f9c6 443#if CONFIG_DNXHD_MUXER
bd09e8a7
BC
444AVOutputFormat 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,
54a73bb5 453 ff_raw_write_packet,
bd09e8a7
BC
454 .flags= AVFMT_NOTIMESTAMPS,
455};
456#endif
457
b250f9c6 458#if CONFIG_DTS_MUXER
76d32428
DB
459AVOutputFormat dts_muxer = {
460 "dts",
461 NULL_IF_CONFIG_SMALL("raw DTS"),
462 "audio/x-dca",
463 "dts",
fda885c7 464 0,
76d32428
DB
465 CODEC_ID_DTS,
466 CODEC_ID_NONE,
fda885c7 467 NULL,
54a73bb5 468 ff_raw_write_packet,
76d32428
DB
469 .flags= AVFMT_NOTIMESTAMPS,
470};
471#endif
472
b250f9c6 473#if CONFIG_EAC3_DEMUXER
2988c93d
JR
474AVInputFormat eac3_demuxer = {
475 "eac3",
476 NULL_IF_CONFIG_SMALL("raw E-AC-3"),
477 0,
478 eac3_probe,
6d0678d1 479 ff_raw_audio_read_header,
81f052cb 480 ff_raw_read_partial_packet,
2988c93d
JR
481 .flags= AVFMT_GENERIC_INDEX,
482 .extensions = "eac3",
483 .value = CODEC_ID_EAC3,
484};
485#endif
486
b250f9c6 487#if CONFIG_EAC3_MUXER
2988c93d
JR
488AVOutputFormat 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,
54a73bb5 497 ff_raw_write_packet,
2988c93d
JR
498 .flags= AVFMT_NOTIMESTAMPS,
499};
500#endif
501
b250f9c6 502#if CONFIG_GSM_DEMUXER
60711e95
MN
503AVInputFormat gsm_demuxer = {
504 "gsm",
b4ee1d39 505 NULL_IF_CONFIG_SMALL("raw GSM"),
60711e95
MN
506 0,
507 NULL,
6d0678d1 508 ff_raw_audio_read_header,
81f052cb 509 ff_raw_read_partial_packet,
60711e95
MN
510 .flags= AVFMT_GENERIC_INDEX,
511 .extensions = "gsm",
512 .value = CODEC_ID_GSM,
513};
7402ee23 514#endif
60711e95 515
b250f9c6 516#if CONFIG_H261_DEMUXER
d2a067d1 517AVInputFormat h261_demuxer = {
c6148de2 518 "h261",
bde15e74 519 NULL_IF_CONFIG_SMALL("raw H.261"),
c6148de2
MN
520 0,
521 h261_probe,
b47a5a95 522 ff_raw_video_read_header,
81f052cb 523 ff_raw_read_partial_packet,
e9b78eeb 524 .flags= AVFMT_GENERIC_INDEX,
c6148de2
MN
525 .extensions = "h261",
526 .value = CODEC_ID_H261,
527};
7402ee23 528#endif
c6148de2 529
b250f9c6 530#if CONFIG_H261_MUXER
d2a067d1 531AVOutputFormat h261_muxer = {
1c3990db 532 "h261",
bde15e74 533 NULL_IF_CONFIG_SMALL("raw H.261"),
1c3990db
MN
534 "video/x-h261",
535 "h261",
536 0,
d9133126 537 CODEC_ID_NONE,
1c3990db 538 CODEC_ID_H261,
7a97dd84 539 NULL,
54a73bb5 540 ff_raw_write_packet,
494bbf58 541 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 542};
082f7acf 543#endif
1c3990db 544
b250f9c6 545#if CONFIG_H263_MUXER
d2a067d1 546AVOutputFormat h263_muxer = {
de6d9b64 547 "h263",
bde15e74 548 NULL_IF_CONFIG_SMALL("raw H.263"),
de6d9b64
FB
549 "video/x-h263",
550 "h263",
551 0,
d9133126 552 CODEC_ID_NONE,
de6d9b64 553 CODEC_ID_H263,
7a97dd84 554 NULL,
54a73bb5 555 ff_raw_write_packet,
494bbf58 556 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 557};
082f7acf 558#endif
c9a65ca8 559
b250f9c6 560#if CONFIG_H264_MUXER
76d32428
DB
561AVOutputFormat 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,
54a73bb5 570 ff_raw_write_packet,
76d32428
DB
571 .flags= AVFMT_NOTIMESTAMPS,
572};
082f7acf 573#endif
76d32428 574
de295976
SG
575#if CONFIG_CAVSVIDEO_MUXER
576AVOutputFormat 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,
54a73bb5 585 ff_raw_write_packet,
de295976 586 .flags= AVFMT_NOTIMESTAMPS,
de295976
SG
587};
588#endif
589
b250f9c6 590#if CONFIG_M4V_MUXER
d2a067d1 591AVOutputFormat m4v_muxer = {
89b3d7c9 592 "m4v",
bde15e74 593 NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
89b3d7c9
MK
594 NULL,
595 "m4v",
596 0,
597 CODEC_ID_NONE,
598 CODEC_ID_MPEG4,
7a97dd84 599 NULL,
54a73bb5 600 ff_raw_write_packet,
494bbf58 601 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 602};
082f7acf 603#endif
89b3d7c9 604
b250f9c6 605#if CONFIG_MJPEG_DEMUXER
76d32428
DB
606AVInputFormat mjpeg_demuxer = {
607 "mjpeg",
b4ee1d39 608 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
0da71265 609 0,
76d32428 610 NULL,
b47a5a95 611 ff_raw_video_read_header,
81f052cb 612 ff_raw_read_partial_packet,
e9b78eeb 613 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
614 .extensions = "mjpg,mjpeg",
615 .value = CODEC_ID_MJPEG,
0da71265 616};
7402ee23 617#endif
0da71265 618
b250f9c6 619#if CONFIG_MJPEG_MUXER
76d32428
DB
620AVOutputFormat mjpeg_muxer = {
621 "mjpeg",
b4ee1d39 622 NULL_IF_CONFIG_SMALL("raw MJPEG video"),
76d32428
DB
623 "video/x-mjpeg",
624 "mjpg,mjpeg",
0da71265
MN
625 0,
626 CODEC_ID_NONE,
76d32428 627 CODEC_ID_MJPEG,
7a97dd84 628 NULL,
54a73bb5 629 ff_raw_write_packet,
494bbf58 630 .flags= AVFMT_NOTIMESTAMPS,
0da71265 631};
082f7acf 632#endif
0da71265 633
b250f9c6 634#if CONFIG_MLP_DEMUXER
76d32428
DB
635AVInputFormat mlp_demuxer = {
636 "mlp",
637 NULL_IF_CONFIG_SMALL("raw MLP"),
c9a65ca8 638 0,
76d32428 639 NULL,
6d0678d1 640 ff_raw_audio_read_header,
81f052cb 641 ff_raw_read_partial_packet,
e9b78eeb 642 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
643 .extensions = "mlp",
644 .value = CODEC_ID_MLP,
de6d9b64 645};
7402ee23 646#endif
de6d9b64 647
0e1ccdeb 648#if CONFIG_MLP_MUXER
9145021d
RP
649AVOutputFormat 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,
54a73bb5 658 ff_raw_write_packet,
9145021d
RP
659 .flags= AVFMT_NOTIMESTAMPS,
660};
661#endif
662
ba2c508d
AJ
663#if CONFIG_SRT_MUXER
664AVOutputFormat srt_muxer = {
665 .name = "srt",
666 .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
667 .mime_type = "application/x-subrip",
668 .extensions = "srt",
54a73bb5 669 .write_packet = ff_raw_write_packet,
ba2c508d
AJ
670 .flags = AVFMT_NOTIMESTAMPS,
671 .subtitle_codec = CODEC_ID_SRT,
672};
673#endif
674
23d9cc45
RP
675#if CONFIG_TRUEHD_DEMUXER
676AVInputFormat truehd_demuxer = {
677 "truehd",
678 NULL_IF_CONFIG_SMALL("raw TrueHD"),
679 0,
680 NULL,
6d0678d1 681 ff_raw_audio_read_header,
23d9cc45
RP
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
690AVOutputFormat 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,
54a73bb5 699 ff_raw_write_packet,
23d9cc45
RP
700 .flags= AVFMT_NOTIMESTAMPS,
701};
702#endif
703
b250f9c6 704#if CONFIG_MPEG1VIDEO_MUXER
d2a067d1 705AVOutputFormat mpeg1video_muxer = {
c9a65ca8 706 "mpeg1video",
b4ee1d39 707 NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
de6d9b64 708 "video/x-mpeg",
e0827ba4 709 "mpg,mpeg,m1v",
de6d9b64 710 0,
d9133126 711 CODEC_ID_NONE,
de6d9b64 712 CODEC_ID_MPEG1VIDEO,
7a97dd84 713 NULL,
54a73bb5 714 ff_raw_write_packet,
494bbf58 715 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 716};
082f7acf 717#endif
de6d9b64 718
b250f9c6 719#if CONFIG_MPEG2VIDEO_MUXER
d2a067d1 720AVOutputFormat mpeg2video_muxer = {
6ec864da 721 "mpeg2video",
b4ee1d39 722 NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
6ec864da
MN
723 NULL,
724 "m2v",
725 0,
d9133126 726 CODEC_ID_NONE,
6ec864da 727 CODEC_ID_MPEG2VIDEO,
7a97dd84 728 NULL,
54a73bb5 729 ff_raw_write_packet,
494bbf58 730 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 731};
082f7acf 732#endif
6ec864da 733
b250f9c6 734#if CONFIG_NULL_MUXER
76d32428
DB
735AVOutputFormat null_muxer = {
736 "null",
b4ee1d39 737 NULL_IF_CONFIG_SMALL("raw null video format"),
76d32428
DB
738 NULL,
739 NULL,
84c63c01 740 0,
85a2aada 741 AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
76d32428 742 CODEC_ID_RAWVIDEO,
84c63c01 743 NULL,
76d32428
DB
744 null_write_packet,
745 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
746};
082f7acf 747#endif
76d32428 748
b250f9c6 749#if CONFIG_RAWVIDEO_DEMUXER
76d32428
DB
750AVInputFormat rawvideo_demuxer = {
751 "rawvideo",
752 NULL_IF_CONFIG_SMALL("raw video format"),
753 0,
754 NULL,
755 raw_read_header,
756 rawvideo_read_packet,
e9b78eeb 757 .flags= AVFMT_GENERIC_INDEX,
76d32428
DB
758 .extensions = "yuv,cif,qcif,rgb",
759 .value = CODEC_ID_RAWVIDEO,
84c63c01 760};
7402ee23 761#endif
84c63c01 762
b250f9c6 763#if CONFIG_RAWVIDEO_MUXER
76d32428
DB
764AVOutputFormat rawvideo_muxer = {
765 "rawvideo",
766 NULL_IF_CONFIG_SMALL("raw video format"),
767 NULL,
768 "yuv,rgb",
5ed8fafc 769 0,
d9133126 770 CODEC_ID_NONE,
76d32428 771 CODEC_ID_RAWVIDEO,
7a97dd84 772 NULL,
54a73bb5 773 ff_raw_write_packet,
494bbf58 774 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 775};
082f7acf 776#endif
5ed8fafc 777
b250f9c6 778#if CONFIG_SHORTEN_DEMUXER
76d32428
DB
779AVInputFormat shorten_demuxer = {
780 "shn",
781 NULL_IF_CONFIG_SMALL("raw Shorten"),
782 0,
783 NULL,
6d0678d1 784 ff_raw_audio_read_header,
81f052cb 785 ff_raw_read_partial_packet,
76d32428
DB
786 .flags= AVFMT_GENERIC_INDEX,
787 .extensions = "shn",
788 .value = CODEC_ID_SHORTEN,
789};
7402ee23 790#endif
76d32428 791
b250f9c6 792#if CONFIG_VC1_DEMUXER
7bb5c2a6
KS
793AVInputFormat vc1_demuxer = {
794 "vc1",
bde15e74 795 NULL_IF_CONFIG_SMALL("raw VC-1"),
7bb5c2a6
KS
796 0,
797 NULL /* vc1_probe */,
b47a5a95 798 ff_raw_video_read_header,
81f052cb 799 ff_raw_read_partial_packet,
7bb5c2a6
KS
800 .extensions = "vc1",
801 .value = CODEC_ID_VC1,
802};
7402ee23 803#endif
7bb5c2a6 804
fb9f1117 805/* PCM formats */
764ef400 806
4986a429 807#define PCMINPUTDEF(name, long_name, ext, codec) \
d2a067d1 808AVInputFormat pcm_ ## name ## _demuxer = {\
764ef400 809 #name,\
bde15e74 810 NULL_IF_CONFIG_SMALL(long_name),\
764ef400
MM
811 0,\
812 NULL,\
813 raw_read_header,\
814 raw_read_packet,\
9b64a036 815 NULL,\
4986a429 816 pcm_read_seek,\
e9b78eeb 817 .flags= AVFMT_GENERIC_INDEX,\
764ef400
MM
818 .extensions = ext,\
819 .value = codec,\
820};
821
2c8e2014 822#define PCMOUTPUTDEF(name, long_name, ext, codec) \
d2a067d1 823AVOutputFormat pcm_ ## name ## _muxer = {\
c9a65ca8 824 #name,\
bde15e74 825 NULL_IF_CONFIG_SMALL(long_name),\
c9a65ca8
FB
826 NULL,\
827 ext,\
828 0,\
829 codec,\
d9133126 830 CODEC_ID_NONE,\
7a97dd84 831 NULL,\
54a73bb5 832 ff_raw_write_packet,\
494bbf58 833 .flags= AVFMT_NOTIMESTAMPS,\
5ed8fafc 834};
2c8e2014
DB
835
836
b250f9c6 837#if !CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
838#define PCMDEF(name, long_name, ext, codec) \
839 PCMINPUTDEF(name, long_name, ext, codec)
b250f9c6 840#elif CONFIG_MUXERS && !CONFIG_DEMUXERS
2c8e2014
DB
841#define PCMDEF(name, long_name, ext, codec) \
842 PCMOUTPUTDEF(name, long_name, ext, codec)
b250f9c6 843#elif CONFIG_MUXERS && CONFIG_DEMUXERS
2c8e2014
DB
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
5ed8fafc 850
63613fe6 851#if HAVE_BIGENDIAN
c9a65ca8
FB
852#define BE_DEF(s) s
853#define LE_DEF(s) NULL
5ed8fafc 854#else
c9a65ca8
FB
855#define BE_DEF(s) NULL
856#define LE_DEF(s) s
5ed8fafc 857#endif
5ed8fafc 858
ee7948cb
PR
859PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
860 NULL, CODEC_ID_PCM_F64BE)
861
862PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
863 NULL, CODEC_ID_PCM_F64LE)
864
865PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
866 NULL, CODEC_ID_PCM_F32BE)
867
868PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
869 NULL, CODEC_ID_PCM_F32LE)
870
871PCMDEF(s32be, "PCM signed 32 bit big-endian format",
872 NULL, CODEC_ID_PCM_S32BE)
873
874PCMDEF(s32le, "PCM signed 32 bit little-endian format",
875 NULL, CODEC_ID_PCM_S32LE)
876
877PCMDEF(s24be, "PCM signed 24 bit big-endian format",
878 NULL, CODEC_ID_PCM_S24BE)
879
880PCMDEF(s24le, "PCM signed 24 bit little-endian format",
881 NULL, CODEC_ID_PCM_S24LE)
5ed8fafc 882
ac1ea66e 883PCMDEF(s16be, "PCM signed 16 bit big-endian format",
c9a65ca8 884 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 885
76d32428
DB
886PCMDEF(s16le, "PCM signed 16 bit little-endian format",
887 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
888
889PCMDEF(s8, "PCM signed 8 bit format",
890 "sb", CODEC_ID_PCM_S8)
5ed8fafc 891
ee7948cb
PR
892PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
893 NULL, CODEC_ID_PCM_U32BE)
894
895PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
896 NULL, CODEC_ID_PCM_U32LE)
897
898PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
899 NULL, CODEC_ID_PCM_U24BE)
900
901PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
902 NULL, CODEC_ID_PCM_U24LE)
903
ac1ea66e 904PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
c9a65ca8 905 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 906
76d32428
DB
907PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
908 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 909
ac1ea66e 910PCMDEF(u8, "PCM unsigned 8 bit format",
c9a65ca8 911 "ub", CODEC_ID_PCM_U8)
5ed8fafc 912
ac1ea66e 913PCMDEF(alaw, "PCM A-law format",
c9a65ca8 914 "al", CODEC_ID_PCM_ALAW)
de6d9b64 915
76d32428
DB
916PCMDEF(mulaw, "PCM mu-law format",
917 "ul", CODEC_ID_PCM_MULAW)