tr -d '\015'
[libav.git] / libavformat / raw.c
CommitLineData
de6d9b64
FB
1/*
2 * RAW encoder and decoder
19720f15 3 * Copyright (c) 2001 Fabrice Bellard.
de6d9b64 4 *
19720f15
FB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
de6d9b64 9 *
19720f15 10 * This library is distributed in the hope that it will be useful,
de6d9b64 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19720f15
FB
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
de6d9b64 14 *
19720f15
FB
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
de6d9b64 18 */
de6d9b64
FB
19#include "avformat.h"
20
764ef400 21#ifdef CONFIG_ENCODERS
de6d9b64 22/* simple formats */
5c91a675 23static int raw_write_header(struct AVFormatContext *s)
de6d9b64
FB
24{
25 return 0;
26}
27
e928649b 28static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
de6d9b64 29{
e928649b 30 put_buffer(&s->pb, pkt->data, pkt->size);
de6d9b64
FB
31 put_flush_packet(&s->pb);
32 return 0;
33}
34
5c91a675 35static int raw_write_trailer(struct AVFormatContext *s)
de6d9b64
FB
36{
37 return 0;
38}
764ef400 39#endif //CONFIG_ENCODERS
de6d9b64
FB
40
41/* raw input */
0c1a9eda 42static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
de6d9b64
FB
43{
44 AVStream *st;
c9a65ca8 45 int id;
de6d9b64 46
c9a65ca8 47 st = av_new_stream(s, 0);
de6d9b64 48 if (!st)
c9a65ca8 49 return AVERROR_NOMEM;
de6d9b64 50 if (ap) {
c9a65ca8
FB
51 id = s->iformat->value;
52 if (id == CODEC_ID_RAWVIDEO) {
de6d9b64 53 st->codec.codec_type = CODEC_TYPE_VIDEO;
de6d9b64 54 } else {
c9a65ca8 55 st->codec.codec_type = CODEC_TYPE_AUDIO;
de6d9b64 56 }
c9a65ca8
FB
57 st->codec.codec_id = id;
58
de6d9b64
FB
59 switch(st->codec.codec_type) {
60 case CODEC_TYPE_AUDIO:
61 st->codec.sample_rate = ap->sample_rate;
62 st->codec.channels = ap->channels;
595bf4ef 63 av_set_pts_info(st, 64, 1, st->codec.sample_rate);
de6d9b64
FB
64 break;
65 case CODEC_TYPE_VIDEO:
c0df9d75 66 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
de6d9b64
FB
67 st->codec.width = ap->width;
68 st->codec.height = ap->height;
bfc7f165
MN
69 st->codec.pix_fmt = ap->pix_fmt;
70 if(st->codec.pix_fmt == PIX_FMT_NONE)
71 st->codec.pix_fmt= PIX_FMT_YUV420P;
de6d9b64
FB
72 break;
73 default:
27e084bd 74 return -1;
de6d9b64
FB
75 }
76 } else {
27e084bd 77 return -1;
de6d9b64
FB
78 }
79 return 0;
80}
81
2e93e3aa 82#define RAW_PACKET_SIZE 1024
de6d9b64 83
5c91a675 84static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 85{
7866eeff 86 int ret, size;
2a6874fd 87 // AVStream *st = s->streams[0];
7866eeff 88
231dd3f3 89 size= RAW_PACKET_SIZE;
de6d9b64 90
7866eeff 91 if (av_new_packet(pkt, size) < 0)
0bd586c5 92 return AVERROR_IO;
de6d9b64
FB
93
94 pkt->stream_index = 0;
7866eeff 95 ret = get_buffer(&s->pb, pkt->data, size);
2e93e3aa 96 if (ret <= 0) {
de6d9b64 97 av_free_packet(pkt);
0bd586c5 98 return AVERROR_IO;
2e93e3aa
FB
99 }
100 /* note: we need to modify the packet size here to handle the last
101 packet */
102 pkt->size = ret;
de6d9b64
FB
103 return ret;
104}
105
e15dec10
LS
106static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
107{
108 int ret, size;
109
110 size = RAW_PACKET_SIZE;
111
112 if (av_new_packet(pkt, size) < 0)
0bd586c5 113 return AVERROR_IO;
e15dec10
LS
114
115 pkt->stream_index = 0;
116 ret = get_partial_buffer(&s->pb, pkt->data, size);
117 if (ret <= 0) {
118 av_free_packet(pkt);
0bd586c5 119 return AVERROR_IO;
e15dec10
LS
120 }
121 pkt->size = ret;
122 return ret;
123}
124
5c91a675 125static int raw_read_close(AVFormatContext *s)
de6d9b64
FB
126{
127 return 0;
128}
129
4986a429 130int pcm_read_seek(AVFormatContext *s,
7b3c1382 131 int stream_index, int64_t timestamp, int flags)
4986a429
FB
132{
133 AVStream *st;
134 int block_align, byte_rate;
135 int64_t pos;
136
137 st = s->streams[0];
138 switch(st->codec.codec_id) {
139 case CODEC_ID_PCM_S16LE:
140 case CODEC_ID_PCM_S16BE:
141 case CODEC_ID_PCM_U16LE:
142 case CODEC_ID_PCM_U16BE:
143 block_align = 2 * st->codec.channels;
144 byte_rate = block_align * st->codec.sample_rate;
145 break;
146 case CODEC_ID_PCM_S8:
147 case CODEC_ID_PCM_U8:
148 case CODEC_ID_PCM_MULAW:
149 case CODEC_ID_PCM_ALAW:
150 block_align = st->codec.channels;
151 byte_rate = block_align * st->codec.sample_rate;
152 break;
153 default:
154 block_align = st->codec.block_align;
155 byte_rate = st->codec.bit_rate / 8;
156 break;
157 }
158
159 if (block_align <= 0 || byte_rate <= 0)
160 return -1;
161
162 /* compute the position by aligning it to block_align */
7b3c1382
MN
163 pos = av_rescale_rnd(timestamp * byte_rate,
164 st->time_base.num,
165 st->time_base.den * (int64_t)block_align,
166 (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
167 pos *= block_align;
4986a429
FB
168
169 /* recompute exact position */
77405fc8 170 st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
4986a429
FB
171 url_fseek(&s->pb, pos + s->data_offset, SEEK_SET);
172 return 0;
173}
174
cd66005d
FB
175/* ac3 read */
176static int ac3_read_header(AVFormatContext *s,
177 AVFormatParameters *ap)
178{
179 AVStream *st;
180
181 st = av_new_stream(s, 0);
182 if (!st)
183 return AVERROR_NOMEM;
184
185 st->codec.codec_type = CODEC_TYPE_AUDIO;
186 st->codec.codec_id = CODEC_ID_AC3;
4986a429 187 st->need_parsing = 1;
cd66005d
FB
188 /* the parameters will be extracted from the compressed bitstream */
189 return 0;
190}
191
85ad5695
MN
192static int shorten_read_header(AVFormatContext *s,
193 AVFormatParameters *ap)
194{
195 AVStream *st;
196
197 st = av_new_stream(s, 0);
198 if (!st)
199 return AVERROR_NOMEM;
200 st->codec.codec_type = CODEC_TYPE_AUDIO;
201 st->codec.codec_id = CODEC_ID_SHORTEN;
202 st->need_parsing = 1;
203 /* the parameters will be extracted from the compressed bitstream */
204 return 0;
205}
206
23c99253
MN
207/* dts read */
208static int dts_read_header(AVFormatContext *s,
209 AVFormatParameters *ap)
210{
211 AVStream *st;
212
213 st = av_new_stream(s, 0);
214 if (!st)
215 return AVERROR_NOMEM;
216
217 st->codec.codec_type = CODEC_TYPE_AUDIO;
218 st->codec.codec_id = CODEC_ID_DTS;
219 st->need_parsing = 1;
220 /* the parameters will be extracted from the compressed bitstream */
221 return 0;
222}
223
de6d9b64
FB
224/* mpeg1/h263 input */
225static int video_read_header(AVFormatContext *s,
226 AVFormatParameters *ap)
227{
228 AVStream *st;
229
c9a65ca8 230 st = av_new_stream(s, 0);
de6d9b64 231 if (!st)
c9a65ca8 232 return AVERROR_NOMEM;
de6d9b64
FB
233
234 st->codec.codec_type = CODEC_TYPE_VIDEO;
c9a65ca8 235 st->codec.codec_id = s->iformat->value;
4986a429
FB
236 st->need_parsing = 1;
237
27e084bd 238 /* for mjpeg, specify frame rate */
7866eeff 239 /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
80ce3254
MN
240 if (ap && ap->time_base.num) {
241 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
242 } else if ( st->codec.codec_id == CODEC_ID_MJPEG ||
243 st->codec.codec_id == CODEC_ID_MPEG4 ||
244 st->codec.codec_id == CODEC_ID_H264) {
245 av_set_pts_info(st, 64, 1, 25);
27e084bd 246 }
80ce3254 247
de6d9b64
FB
248 return 0;
249}
250
c9a65ca8
FB
251#define SEQ_START_CODE 0x000001b3
252#define GOP_START_CODE 0x000001b8
253#define PICTURE_START_CODE 0x00000100
254
255/* XXX: improve that by looking at several start codes */
256static int mpegvideo_probe(AVProbeData *p)
257{
fa777321
FB
258 int code;
259 const uint8_t *d;
c9a65ca8
FB
260
261 /* we search the first start code. If it is a sequence, gop or
262 picture start code then we decide it is an mpeg video
263 stream. We do not send highest value to give a chance to mpegts */
fa777321
FB
264 /* NOTE: the search range was restricted to avoid too many false
265 detections */
266
267 if (p->buf_size < 6)
268 return 0;
269 d = p->buf;
270 code = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]);
271 if ((code & 0xffffff00) == 0x100) {
272 if (code == SEQ_START_CODE ||
273 code == GOP_START_CODE ||
274 code == PICTURE_START_CODE)
275 return 50 - 1;
276 else
277 return 0;
c9a65ca8
FB
278 }
279 return 0;
280}
281
d07f9043
MN
282static int h263_probe(AVProbeData *p)
283{
284 int code;
285 const uint8_t *d;
286
287 if (p->buf_size < 6)
288 return 0;
289 d = p->buf;
290 code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
291 if (code == 0x20) {
292 return 50;
293 }
294 return 0;
295}
296
c6148de2
MN
297static int h261_probe(AVProbeData *p)
298{
299 int code;
300 const uint8_t *d;
301
302 if (p->buf_size < 6)
303 return 0;
304 d = p->buf;
305 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
306 if (code == 0x10) {
307 return 50;
308 }
309 return 0;
310}
311
85ad5695
MN
312AVInputFormat shorten_iformat = {
313 "shn",
314 "raw shn",
315 0,
316 NULL,
317 shorten_read_header,
318 raw_read_partial_packet,
319 raw_read_close,
320 .extensions = "shn",
321};
322
c9a65ca8
FB
323AVInputFormat ac3_iformat = {
324 "ac3",
325 "raw ac3",
326 0,
327 NULL,
cd66005d 328 ac3_read_header,
e15dec10 329 raw_read_partial_packet,
de6d9b64 330 raw_read_close,
bb76a117 331 .extensions = "ac3",
de6d9b64
FB
332};
333
764ef400 334#ifdef CONFIG_ENCODERS
c9a65ca8 335AVOutputFormat ac3_oformat = {
de6d9b64
FB
336 "ac3",
337 "raw ac3",
338 "audio/x-ac3",
339 "ac3",
c9a65ca8 340 0,
de6d9b64
FB
341 CODEC_ID_AC3,
342 0,
343 raw_write_header,
344 raw_write_packet,
345 raw_write_trailer,
346};
764ef400 347#endif //CONFIG_ENCODERS
de6d9b64 348
23c99253
MN
349AVInputFormat dts_iformat = {
350 "dts",
351 "raw dts",
352 0,
353 NULL,
354 dts_read_header,
355 raw_read_partial_packet,
356 raw_read_close,
357 .extensions = "dts",
358};
359
c6148de2
MN
360AVInputFormat h261_iformat = {
361 "h261",
362 "raw h261",
363 0,
364 h261_probe,
365 video_read_header,
366 raw_read_partial_packet,
367 raw_read_close,
368 .extensions = "h261",
369 .value = CODEC_ID_H261,
370};
371
1c3990db
MN
372#ifdef CONFIG_ENCODERS
373AVOutputFormat h261_oformat = {
374 "h261",
375 "raw h261",
376 "video/x-h261",
377 "h261",
378 0,
379 0,
380 CODEC_ID_H261,
381 raw_write_header,
382 raw_write_packet,
383 raw_write_trailer,
384};
385#endif //CONFIG_ENCODERS
386
d07f9043
MN
387AVInputFormat h263_iformat = {
388 "h263",
389 "raw h263",
390 0,
391 h263_probe,
392 video_read_header,
e15dec10 393 raw_read_partial_packet,
d07f9043
MN
394 raw_read_close,
395// .extensions = "h263", //FIXME remove after writing mpeg4_probe
396 .value = CODEC_ID_H263,
397};
398
764ef400 399#ifdef CONFIG_ENCODERS
c9a65ca8 400AVOutputFormat h263_oformat = {
de6d9b64
FB
401 "h263",
402 "raw h263",
403 "video/x-h263",
404 "h263",
405 0,
c9a65ca8 406 0,
de6d9b64
FB
407 CODEC_ID_H263,
408 raw_write_header,
409 raw_write_packet,
410 raw_write_trailer,
c9a65ca8 411};
764ef400 412#endif //CONFIG_ENCODERS
c9a65ca8 413
7866eeff
MN
414AVInputFormat m4v_iformat = {
415 "m4v",
416 "raw MPEG4 video format",
417 0,
2f0f5b20 418 NULL /*mpegvideo_probe*/,
7866eeff 419 video_read_header,
e15dec10 420 raw_read_partial_packet,
7866eeff 421 raw_read_close,
bb76a117
MR
422 .extensions = "m4v", //FIXME remove after writing mpeg4_probe
423 .value = CODEC_ID_MPEG4,
7866eeff
MN
424};
425
764ef400 426#ifdef CONFIG_ENCODERS
89b3d7c9
MK
427AVOutputFormat m4v_oformat = {
428 "m4v",
429 "raw MPEG4 video format",
430 NULL,
431 "m4v",
432 0,
433 CODEC_ID_NONE,
434 CODEC_ID_MPEG4,
435 raw_write_header,
436 raw_write_packet,
437 raw_write_trailer,
438};
764ef400 439#endif //CONFIG_ENCODERS
89b3d7c9 440
0da71265
MN
441AVInputFormat h264_iformat = {
442 "h264",
443 "raw H264 video format",
444 0,
445 NULL /*mpegvideo_probe*/,
446 video_read_header,
e15dec10 447 raw_read_partial_packet,
0da71265
MN
448 raw_read_close,
449 .extensions = "h26l,h264", //FIXME remove after writing mpeg4_probe
450 .value = CODEC_ID_H264,
451};
452
764ef400 453#ifdef CONFIG_ENCODERS
0da71265
MN
454AVOutputFormat h264_oformat = {
455 "h264",
456 "raw H264 video format",
457 NULL,
458 "h264",
459 0,
460 CODEC_ID_NONE,
461 CODEC_ID_H264,
462 raw_write_header,
463 raw_write_packet,
464 raw_write_trailer,
465};
764ef400 466#endif //CONFIG_ENCODERS
0da71265 467
c9a65ca8
FB
468AVInputFormat mpegvideo_iformat = {
469 "mpegvideo",
470 "MPEG video",
471 0,
472 mpegvideo_probe,
de6d9b64 473 video_read_header,
e15dec10 474 raw_read_partial_packet,
de6d9b64 475 raw_read_close,
bb76a117 476 .value = CODEC_ID_MPEG1VIDEO,
de6d9b64
FB
477};
478
764ef400 479#ifdef CONFIG_ENCODERS
c9a65ca8
FB
480AVOutputFormat mpeg1video_oformat = {
481 "mpeg1video",
de6d9b64
FB
482 "MPEG video",
483 "video/x-mpeg",
484 "mpg,mpeg",
485 0,
c9a65ca8 486 0,
de6d9b64
FB
487 CODEC_ID_MPEG1VIDEO,
488 raw_write_header,
489 raw_write_packet,
490 raw_write_trailer,
de6d9b64 491};
764ef400 492#endif //CONFIG_ENCODERS
de6d9b64 493
6ec864da
MN
494#ifdef CONFIG_ENCODERS
495AVOutputFormat mpeg2video_oformat = {
496 "mpeg2video",
497 "MPEG2 video",
498 NULL,
499 "m2v",
500 0,
501 0,
502 CODEC_ID_MPEG2VIDEO,
503 raw_write_header,
504 raw_write_packet,
505 raw_write_trailer,
506};
507#endif //CONFIG_ENCODERS
508
c9a65ca8 509AVInputFormat mjpeg_iformat = {
27e084bd
FB
510 "mjpeg",
511 "MJPEG video",
27e084bd 512 0,
c9a65ca8 513 NULL,
27e084bd 514 video_read_header,
e15dec10 515 raw_read_partial_packet,
27e084bd 516 raw_read_close,
bb76a117
MR
517 .extensions = "mjpg,mjpeg",
518 .value = CODEC_ID_MJPEG,
27e084bd
FB
519};
520
764ef400 521#ifdef CONFIG_ENCODERS
c9a65ca8
FB
522AVOutputFormat mjpeg_oformat = {
523 "mjpeg",
524 "MJPEG video",
525 "video/x-mjpeg",
526 "mjpg,mjpeg",
5ed8fafc 527 0,
5ed8fafc 528 0,
c9a65ca8 529 CODEC_ID_MJPEG,
5ed8fafc
FB
530 raw_write_header,
531 raw_write_packet,
532 raw_write_trailer,
5ed8fafc 533};
764ef400 534#endif //CONFIG_ENCODERS
5ed8fafc 535
c9a65ca8 536/* pcm formats */
764ef400 537
4986a429 538#define PCMINPUTDEF(name, long_name, ext, codec) \
764ef400
MM
539AVInputFormat pcm_ ## name ## _iformat = {\
540 #name,\
541 long_name,\
542 0,\
543 NULL,\
544 raw_read_header,\
545 raw_read_packet,\
546 raw_read_close,\
4986a429 547 pcm_read_seek,\
764ef400
MM
548 .extensions = ext,\
549 .value = codec,\
550};
551
4986a429
FB
552#if !defined(CONFIG_ENCODERS) && defined(CONFIG_DECODERS)
553
554#define PCMDEF(name, long_name, ext, codec) \
555 PCMINPUTDEF(name, long_name, ext, codec)
556
764ef400 557#else
5ed8fafc 558
c9a65ca8 559#define PCMDEF(name, long_name, ext, codec) \
4986a429 560 PCMINPUTDEF(name, long_name, ext, codec)\
c9a65ca8
FB
561\
562AVOutputFormat pcm_ ## name ## _oformat = {\
563 #name,\
564 long_name,\
565 NULL,\
566 ext,\
567 0,\
568 codec,\
569 0,\
570 raw_write_header,\
571 raw_write_packet,\
572 raw_write_trailer,\
5ed8fafc 573};
764ef400 574#endif //CONFIG_ENCODERS
5ed8fafc 575
5ed8fafc 576#ifdef WORDS_BIGENDIAN
c9a65ca8
FB
577#define BE_DEF(s) s
578#define LE_DEF(s) NULL
5ed8fafc 579#else
c9a65ca8
FB
580#define BE_DEF(s) NULL
581#define LE_DEF(s) s
5ed8fafc 582#endif
5ed8fafc 583
5ed8fafc 584
c9a65ca8
FB
585PCMDEF(s16le, "pcm signed 16 bit little endian format",
586 LE_DEF("sw"), CODEC_ID_PCM_S16LE)
5ed8fafc 587
c9a65ca8
FB
588PCMDEF(s16be, "pcm signed 16 bit big endian format",
589 BE_DEF("sw"), CODEC_ID_PCM_S16BE)
5ed8fafc 590
c9a65ca8
FB
591PCMDEF(u16le, "pcm unsigned 16 bit little endian format",
592 LE_DEF("uw"), CODEC_ID_PCM_U16LE)
5ed8fafc 593
c9a65ca8
FB
594PCMDEF(u16be, "pcm unsigned 16 bit big endian format",
595 BE_DEF("uw"), CODEC_ID_PCM_U16BE)
5ed8fafc 596
c9a65ca8
FB
597PCMDEF(s8, "pcm signed 8 bit format",
598 "sb", CODEC_ID_PCM_S8)
5ed8fafc 599
c9a65ca8
FB
600PCMDEF(u8, "pcm unsigned 8 bit format",
601 "ub", CODEC_ID_PCM_U8)
5ed8fafc 602
c9a65ca8
FB
603PCMDEF(mulaw, "pcm mu law format",
604 "ul", CODEC_ID_PCM_MULAW)
de6d9b64 605
c9a65ca8
FB
606PCMDEF(alaw, "pcm A law format",
607 "al", CODEC_ID_PCM_ALAW)
de6d9b64 608
5c91a675 609static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64
FB
610{
611 int packet_size, ret, width, height;
612 AVStream *st = s->streams[0];
613
614 width = st->codec.width;
615 height = st->codec.height;
616
63167088
RS
617 packet_size = avpicture_get_size(st->codec.pix_fmt, width, height);
618 if (packet_size < 0)
71c32f19 619 return -1;
de6d9b64
FB
620
621 if (av_new_packet(pkt, packet_size) < 0)
0bd586c5 622 return AVERROR_IO;
de6d9b64
FB
623
624 pkt->stream_index = 0;
c2c2cd2d 625#if 0
de6d9b64
FB
626 /* bypass buffered I/O */
627 ret = url_read(url_fileno(&s->pb), pkt->data, pkt->size);
c2c2cd2d
MN
628#else
629 ret = get_buffer(&s->pb, pkt->data, pkt->size);
630#endif
de6d9b64
FB
631 if (ret != pkt->size) {
632 av_free_packet(pkt);
0bd586c5 633 return AVERROR_IO;
de6d9b64
FB
634 } else {
635 return 0;
636 }
637}
638
c9a65ca8
FB
639AVInputFormat rawvideo_iformat = {
640 "rawvideo",
641 "raw video format",
642 0,
643 NULL,
644 raw_read_header,
645 rawvideo_read_packet,
646 raw_read_close,
bfc7f165 647 .extensions = "yuv,cif,qcif",
bb76a117 648 .value = CODEC_ID_RAWVIDEO,
c9a65ca8
FB
649};
650
764ef400 651#ifdef CONFIG_ENCODERS
c9a65ca8 652AVOutputFormat rawvideo_oformat = {
de6d9b64
FB
653 "rawvideo",
654 "raw video format",
655 NULL,
656 "yuv",
c9a65ca8 657 0,
de6d9b64
FB
658 CODEC_ID_NONE,
659 CODEC_ID_RAWVIDEO,
660 raw_write_header,
661 raw_write_packet,
662 raw_write_trailer,
de6d9b64 663};
764ef400 664#endif //CONFIG_ENCODERS
c9a65ca8 665
764ef400 666#ifdef CONFIG_ENCODERS
e928649b 667static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
87bdd3e5
FB
668{
669 return 0;
670}
671
672AVOutputFormat null_oformat = {
673 "null",
674 "null video format",
675 NULL,
676 NULL,
677 0,
678#ifdef WORDS_BIGENDIAN
679 CODEC_ID_PCM_S16BE,
680#else
681 CODEC_ID_PCM_S16LE,
682#endif
683 CODEC_ID_RAWVIDEO,
684 raw_write_header,
685 null_write_packet,
686 raw_write_trailer,
b1d89f82 687 .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE,
87bdd3e5 688};
764ef400
MM
689#endif //CONFIG_ENCODERS
690
691#ifndef CONFIG_ENCODERS
692#define av_register_output_format(format)
693#endif
694#ifndef CONFIG_DECODERS
695#define av_register_input_format(format)
696#endif
87bdd3e5 697
c9a65ca8
FB
698int raw_init(void)
699{
85ad5695
MN
700
701 av_register_input_format(&shorten_iformat);
702
c9a65ca8
FB
703 av_register_input_format(&ac3_iformat);
704 av_register_output_format(&ac3_oformat);
705
23c99253
MN
706 av_register_input_format(&dts_iformat);
707
c6148de2 708 av_register_input_format(&h261_iformat);
1c3990db 709 av_register_output_format(&h261_oformat);
c6148de2 710
d07f9043 711 av_register_input_format(&h263_iformat);
c9a65ca8 712 av_register_output_format(&h263_oformat);
89b3d7c9 713
7866eeff 714 av_register_input_format(&m4v_iformat);
89b3d7c9 715 av_register_output_format(&m4v_oformat);
0da71265
MN
716
717 av_register_input_format(&h264_iformat);
718 av_register_output_format(&h264_oformat);
c9a65ca8
FB
719
720 av_register_input_format(&mpegvideo_iformat);
721 av_register_output_format(&mpeg1video_oformat);
722
6ec864da
MN
723 av_register_output_format(&mpeg2video_oformat);
724
c9a65ca8
FB
725 av_register_input_format(&mjpeg_iformat);
726 av_register_output_format(&mjpeg_oformat);
727
728 av_register_input_format(&pcm_s16le_iformat);
729 av_register_output_format(&pcm_s16le_oformat);
730 av_register_input_format(&pcm_s16be_iformat);
731 av_register_output_format(&pcm_s16be_oformat);
732 av_register_input_format(&pcm_u16le_iformat);
733 av_register_output_format(&pcm_u16le_oformat);
734 av_register_input_format(&pcm_u16be_iformat);
735 av_register_output_format(&pcm_u16be_oformat);
736 av_register_input_format(&pcm_s8_iformat);
737 av_register_output_format(&pcm_s8_oformat);
738 av_register_input_format(&pcm_u8_iformat);
739 av_register_output_format(&pcm_u8_oformat);
740 av_register_input_format(&pcm_mulaw_iformat);
741 av_register_output_format(&pcm_mulaw_oformat);
742 av_register_input_format(&pcm_alaw_iformat);
743 av_register_output_format(&pcm_alaw_oformat);
744
745 av_register_input_format(&rawvideo_iformat);
746 av_register_output_format(&rawvideo_oformat);
87bdd3e5
FB
747
748 av_register_output_format(&null_oformat);
c9a65ca8
FB
749 return 0;
750}