Statistics
| Branch: | Revision:

ffmpeg / libavformat / raw.c @ 99392a61

History | View | Annotate | Download (20.1 KB)

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_DIRAC_DEMUXER
245
static int dirac_probe(AVProbeData *p)
246
{
247
    if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
248
        return AVPROBE_SCORE_MAX;
249
    else
250
        return 0;
251
}
252
#endif
253

    
254
#if CONFIG_DNXHD_DEMUXER
255
static int dnxhd_probe(AVProbeData *p)
256
{
257
    static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
258
    int w, h, compression_id;
259
    if (p->buf_size < 0x2c)
260
        return 0;
261
    if (memcmp(p->buf, header, 5))
262
        return 0;
263
    h = AV_RB16(p->buf + 0x18);
264
    w = AV_RB16(p->buf + 0x1a);
265
    if (!w || !h)
266
        return 0;
267
    compression_id = AV_RB32(p->buf + 0x28);
268
    if (compression_id < 1237 || compression_id > 1253)
269
        return 0;
270
    return AVPROBE_SCORE_MAX;
271
}
272
#endif
273

    
274
#if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
275
static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
276
{
277
    int max_frames, first_frames = 0, frames;
278
    uint8_t *buf, *buf2, *end;
279
    AC3HeaderInfo hdr;
280
    GetBitContext gbc;
281
    enum CodecID codec_id = CODEC_ID_AC3;
282

    
283
    max_frames = 0;
284
    buf = p->buf;
285
    end = buf + p->buf_size;
286

    
287
    for(; buf < end; buf++) {
288
        buf2 = buf;
289

    
290
        for(frames = 0; buf2 < end; frames++) {
291
            init_get_bits(&gbc, buf2, 54);
292
            if(ff_ac3_parse_header(&gbc, &hdr) < 0)
293
                break;
294
            if(buf2 + hdr.frame_size > end ||
295
               av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
296
                break;
297
            if (hdr.bitstream_id > 10)
298
                codec_id = CODEC_ID_EAC3;
299
            buf2 += hdr.frame_size;
300
        }
301
        max_frames = FFMAX(max_frames, frames);
302
        if(buf == p->buf)
303
            first_frames = frames;
304
    }
305
    if(codec_id != expected_codec_id) return 0;
306
    // keep this in sync with mp3 probe, both need to avoid
307
    // issues with MPEG-files!
308
    if   (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
309
    else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
310
    else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
311
    else if(max_frames>=1) return 1;
312
    else                   return 0;
313
}
314
#endif
315

    
316
#if CONFIG_AC3_DEMUXER
317
static int ac3_probe(AVProbeData *p)
318
{
319
    return ac3_eac3_probe(p, CODEC_ID_AC3);
320
}
321
#endif
322

    
323
#if CONFIG_EAC3_DEMUXER
324
static int eac3_probe(AVProbeData *p)
325
{
326
    return ac3_eac3_probe(p, CODEC_ID_EAC3);
327
}
328
#endif
329

    
330
/* Note: Do not forget to add new entries to the Makefile as well. */
331

    
332
#if CONFIG_AC3_DEMUXER
333
AVInputFormat ac3_demuxer = {
334
    "ac3",
335
    NULL_IF_CONFIG_SMALL("raw AC-3"),
336
    0,
337
    ac3_probe,
338
    ff_raw_audio_read_header,
339
    ff_raw_read_partial_packet,
340
    .flags= AVFMT_GENERIC_INDEX,
341
    .extensions = "ac3",
342
    .value = CODEC_ID_AC3,
343
};
344
#endif
345

    
346
#if CONFIG_AC3_MUXER
347
AVOutputFormat ac3_muxer = {
348
    "ac3",
349
    NULL_IF_CONFIG_SMALL("raw AC-3"),
350
    "audio/x-ac3",
351
    "ac3",
352
    0,
353
    CODEC_ID_AC3,
354
    CODEC_ID_NONE,
355
    NULL,
356
    ff_raw_write_packet,
357
    .flags= AVFMT_NOTIMESTAMPS,
358
};
359
#endif
360

    
361
#if CONFIG_DIRAC_DEMUXER
362
AVInputFormat dirac_demuxer = {
363
    "dirac",
364
    NULL_IF_CONFIG_SMALL("raw Dirac"),
365
    0,
366
    dirac_probe,
367
    ff_raw_video_read_header,
368
    ff_raw_read_partial_packet,
369
    .flags= AVFMT_GENERIC_INDEX,
370
    .value = CODEC_ID_DIRAC,
371
};
372
#endif
373

    
374
#if CONFIG_DIRAC_MUXER
375
AVOutputFormat dirac_muxer = {
376
    "dirac",
377
    NULL_IF_CONFIG_SMALL("raw Dirac"),
378
    NULL,
379
    "drc",
380
    0,
381
    CODEC_ID_NONE,
382
    CODEC_ID_DIRAC,
383
    NULL,
384
    ff_raw_write_packet,
385
    .flags= AVFMT_NOTIMESTAMPS,
386
};
387
#endif
388

    
389
#if CONFIG_DNXHD_DEMUXER
390
AVInputFormat dnxhd_demuxer = {
391
    "dnxhd",
392
    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
393
    0,
394
    dnxhd_probe,
395
    ff_raw_video_read_header,
396
    ff_raw_read_partial_packet,
397
    .flags= AVFMT_GENERIC_INDEX,
398
    .value = CODEC_ID_DNXHD,
399
};
400
#endif
401

    
402
#if CONFIG_DNXHD_MUXER
403
AVOutputFormat dnxhd_muxer = {
404
    "dnxhd",
405
    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
406
    NULL,
407
    "dnxhd",
408
    0,
409
    CODEC_ID_NONE,
410
    CODEC_ID_DNXHD,
411
    NULL,
412
    ff_raw_write_packet,
413
    .flags= AVFMT_NOTIMESTAMPS,
414
};
415
#endif
416

    
417
#if CONFIG_DTS_MUXER
418
AVOutputFormat dts_muxer = {
419
    "dts",
420
    NULL_IF_CONFIG_SMALL("raw DTS"),
421
    "audio/x-dca",
422
    "dts",
423
    0,
424
    CODEC_ID_DTS,
425
    CODEC_ID_NONE,
426
    NULL,
427
    ff_raw_write_packet,
428
    .flags= AVFMT_NOTIMESTAMPS,
429
};
430
#endif
431

    
432
#if CONFIG_EAC3_DEMUXER
433
AVInputFormat eac3_demuxer = {
434
    "eac3",
435
    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
436
    0,
437
    eac3_probe,
438
    ff_raw_audio_read_header,
439
    ff_raw_read_partial_packet,
440
    .flags= AVFMT_GENERIC_INDEX,
441
    .extensions = "eac3",
442
    .value = CODEC_ID_EAC3,
443
};
444
#endif
445

    
446
#if CONFIG_EAC3_MUXER
447
AVOutputFormat eac3_muxer = {
448
    "eac3",
449
    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
450
    "audio/x-eac3",
451
    "eac3",
452
    0,
453
    CODEC_ID_EAC3,
454
    CODEC_ID_NONE,
455
    NULL,
456
    ff_raw_write_packet,
457
    .flags= AVFMT_NOTIMESTAMPS,
458
};
459
#endif
460

    
461
#if CONFIG_GSM_DEMUXER
462
AVInputFormat gsm_demuxer = {
463
    "gsm",
464
    NULL_IF_CONFIG_SMALL("raw GSM"),
465
    0,
466
    NULL,
467
    ff_raw_audio_read_header,
468
    ff_raw_read_partial_packet,
469
    .flags= AVFMT_GENERIC_INDEX,
470
    .extensions = "gsm",
471
    .value = CODEC_ID_GSM,
472
};
473
#endif
474

    
475
#if CONFIG_H261_MUXER
476
AVOutputFormat h261_muxer = {
477
    "h261",
478
    NULL_IF_CONFIG_SMALL("raw H.261"),
479
    "video/x-h261",
480
    "h261",
481
    0,
482
    CODEC_ID_NONE,
483
    CODEC_ID_H261,
484
    NULL,
485
    ff_raw_write_packet,
486
    .flags= AVFMT_NOTIMESTAMPS,
487
};
488
#endif
489

    
490
#if CONFIG_H263_MUXER
491
AVOutputFormat h263_muxer = {
492
    "h263",
493
    NULL_IF_CONFIG_SMALL("raw H.263"),
494
    "video/x-h263",
495
    "h263",
496
    0,
497
    CODEC_ID_NONE,
498
    CODEC_ID_H263,
499
    NULL,
500
    ff_raw_write_packet,
501
    .flags= AVFMT_NOTIMESTAMPS,
502
};
503
#endif
504

    
505
#if CONFIG_H264_MUXER
506
AVOutputFormat h264_muxer = {
507
    "h264",
508
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
509
    NULL,
510
    "h264",
511
    0,
512
    CODEC_ID_NONE,
513
    CODEC_ID_H264,
514
    NULL,
515
    ff_raw_write_packet,
516
    .flags= AVFMT_NOTIMESTAMPS,
517
};
518
#endif
519

    
520
#if CONFIG_CAVSVIDEO_MUXER
521
AVOutputFormat cavsvideo_muxer = {
522
    "cavsvideo",
523
    NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
524
    NULL,
525
    "cavs",
526
    0,
527
    CODEC_ID_NONE,
528
    CODEC_ID_CAVS,
529
    NULL,
530
    ff_raw_write_packet,
531
    .flags= AVFMT_NOTIMESTAMPS,
532
};
533
#endif
534

    
535
#if CONFIG_M4V_MUXER
536
AVOutputFormat m4v_muxer = {
537
    "m4v",
538
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
539
    NULL,
540
    "m4v",
541
    0,
542
    CODEC_ID_NONE,
543
    CODEC_ID_MPEG4,
544
    NULL,
545
    ff_raw_write_packet,
546
    .flags= AVFMT_NOTIMESTAMPS,
547
};
548
#endif
549

    
550
#if CONFIG_MJPEG_DEMUXER
551
AVInputFormat mjpeg_demuxer = {
552
    "mjpeg",
553
    NULL_IF_CONFIG_SMALL("raw MJPEG video"),
554
    0,
555
    NULL,
556
    ff_raw_video_read_header,
557
    ff_raw_read_partial_packet,
558
    .flags= AVFMT_GENERIC_INDEX,
559
    .extensions = "mjpg,mjpeg",
560
    .value = CODEC_ID_MJPEG,
561
};
562
#endif
563

    
564
#if CONFIG_MJPEG_MUXER
565
AVOutputFormat mjpeg_muxer = {
566
    "mjpeg",
567
    NULL_IF_CONFIG_SMALL("raw MJPEG video"),
568
    "video/x-mjpeg",
569
    "mjpg,mjpeg",
570
    0,
571
    CODEC_ID_NONE,
572
    CODEC_ID_MJPEG,
573
    NULL,
574
    ff_raw_write_packet,
575
    .flags= AVFMT_NOTIMESTAMPS,
576
};
577
#endif
578

    
579
#if CONFIG_MLP_DEMUXER
580
AVInputFormat mlp_demuxer = {
581
    "mlp",
582
    NULL_IF_CONFIG_SMALL("raw MLP"),
583
    0,
584
    NULL,
585
    ff_raw_audio_read_header,
586
    ff_raw_read_partial_packet,
587
    .flags= AVFMT_GENERIC_INDEX,
588
    .extensions = "mlp",
589
    .value = CODEC_ID_MLP,
590
};
591
#endif
592

    
593
#if CONFIG_MLP_MUXER
594
AVOutputFormat mlp_muxer = {
595
    "mlp",
596
    NULL_IF_CONFIG_SMALL("raw MLP"),
597
    NULL,
598
    "mlp",
599
    0,
600
    CODEC_ID_MLP,
601
    CODEC_ID_NONE,
602
    NULL,
603
    ff_raw_write_packet,
604
    .flags= AVFMT_NOTIMESTAMPS,
605
};
606
#endif
607

    
608
#if CONFIG_SRT_MUXER
609
AVOutputFormat srt_muxer = {
610
    .name           = "srt",
611
    .long_name      = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
612
    .mime_type      = "application/x-subrip",
613
    .extensions     = "srt",
614
    .write_packet   = ff_raw_write_packet,
615
    .flags          = AVFMT_NOTIMESTAMPS,
616
    .subtitle_codec = CODEC_ID_SRT,
617
};
618
#endif
619

    
620
#if CONFIG_TRUEHD_DEMUXER
621
AVInputFormat truehd_demuxer = {
622
    "truehd",
623
    NULL_IF_CONFIG_SMALL("raw TrueHD"),
624
    0,
625
    NULL,
626
    ff_raw_audio_read_header,
627
    ff_raw_read_partial_packet,
628
    .flags= AVFMT_GENERIC_INDEX,
629
    .extensions = "thd",
630
    .value = CODEC_ID_TRUEHD,
631
};
632
#endif
633

    
634
#if CONFIG_TRUEHD_MUXER
635
AVOutputFormat truehd_muxer = {
636
    "truehd",
637
    NULL_IF_CONFIG_SMALL("raw TrueHD"),
638
    NULL,
639
    "thd",
640
    0,
641
    CODEC_ID_TRUEHD,
642
    CODEC_ID_NONE,
643
    NULL,
644
    ff_raw_write_packet,
645
    .flags= AVFMT_NOTIMESTAMPS,
646
};
647
#endif
648

    
649
#if CONFIG_MPEG1VIDEO_MUXER
650
AVOutputFormat mpeg1video_muxer = {
651
    "mpeg1video",
652
    NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
653
    "video/x-mpeg",
654
    "mpg,mpeg,m1v",
655
    0,
656
    CODEC_ID_NONE,
657
    CODEC_ID_MPEG1VIDEO,
658
    NULL,
659
    ff_raw_write_packet,
660
    .flags= AVFMT_NOTIMESTAMPS,
661
};
662
#endif
663

    
664
#if CONFIG_MPEG2VIDEO_MUXER
665
AVOutputFormat mpeg2video_muxer = {
666
    "mpeg2video",
667
    NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
668
    NULL,
669
    "m2v",
670
    0,
671
    CODEC_ID_NONE,
672
    CODEC_ID_MPEG2VIDEO,
673
    NULL,
674
    ff_raw_write_packet,
675
    .flags= AVFMT_NOTIMESTAMPS,
676
};
677
#endif
678

    
679
#if CONFIG_NULL_MUXER
680
AVOutputFormat null_muxer = {
681
    "null",
682
    NULL_IF_CONFIG_SMALL("raw null video format"),
683
    NULL,
684
    NULL,
685
    0,
686
    AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
687
    CODEC_ID_RAWVIDEO,
688
    NULL,
689
    null_write_packet,
690
    .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
691
};
692
#endif
693

    
694
#if CONFIG_RAWVIDEO_DEMUXER
695
AVInputFormat rawvideo_demuxer = {
696
    "rawvideo",
697
    NULL_IF_CONFIG_SMALL("raw video format"),
698
    0,
699
    NULL,
700
    raw_read_header,
701
    rawvideo_read_packet,
702
    .flags= AVFMT_GENERIC_INDEX,
703
    .extensions = "yuv,cif,qcif,rgb",
704
    .value = CODEC_ID_RAWVIDEO,
705
};
706
#endif
707

    
708
#if CONFIG_RAWVIDEO_MUXER
709
AVOutputFormat rawvideo_muxer = {
710
    "rawvideo",
711
    NULL_IF_CONFIG_SMALL("raw video format"),
712
    NULL,
713
    "yuv,rgb",
714
    0,
715
    CODEC_ID_NONE,
716
    CODEC_ID_RAWVIDEO,
717
    NULL,
718
    ff_raw_write_packet,
719
    .flags= AVFMT_NOTIMESTAMPS,
720
};
721
#endif
722

    
723
#if CONFIG_SHORTEN_DEMUXER
724
AVInputFormat shorten_demuxer = {
725
    "shn",
726
    NULL_IF_CONFIG_SMALL("raw Shorten"),
727
    0,
728
    NULL,
729
    ff_raw_audio_read_header,
730
    ff_raw_read_partial_packet,
731
    .flags= AVFMT_GENERIC_INDEX,
732
    .extensions = "shn",
733
    .value = CODEC_ID_SHORTEN,
734
};
735
#endif
736

    
737
#if CONFIG_VC1_DEMUXER
738
AVInputFormat vc1_demuxer = {
739
    "vc1",
740
    NULL_IF_CONFIG_SMALL("raw VC-1"),
741
    0,
742
    NULL /* vc1_probe */,
743
    ff_raw_video_read_header,
744
    ff_raw_read_partial_packet,
745
    .extensions = "vc1",
746
    .value = CODEC_ID_VC1,
747
};
748
#endif
749

    
750
/* PCM formats */
751

    
752
#define PCMINPUTDEF(name, long_name, ext, codec) \
753
AVInputFormat pcm_ ## name ## _demuxer = {\
754
    #name,\
755
    NULL_IF_CONFIG_SMALL(long_name),\
756
    0,\
757
    NULL,\
758
    raw_read_header,\
759
    raw_read_packet,\
760
    NULL,\
761
    pcm_read_seek,\
762
    .flags= AVFMT_GENERIC_INDEX,\
763
    .extensions = ext,\
764
    .value = codec,\
765
};
766

    
767
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
768
AVOutputFormat pcm_ ## name ## _muxer = {\
769
    #name,\
770
    NULL_IF_CONFIG_SMALL(long_name),\
771
    NULL,\
772
    ext,\
773
    0,\
774
    codec,\
775
    CODEC_ID_NONE,\
776
    NULL,\
777
    ff_raw_write_packet,\
778
    .flags= AVFMT_NOTIMESTAMPS,\
779
};
780

    
781

    
782
#if  !CONFIG_MUXERS && CONFIG_DEMUXERS
783
#define PCMDEF(name, long_name, ext, codec) \
784
        PCMINPUTDEF(name, long_name, ext, codec)
785
#elif CONFIG_MUXERS && !CONFIG_DEMUXERS
786
#define PCMDEF(name, long_name, ext, codec) \
787
        PCMOUTPUTDEF(name, long_name, ext, codec)
788
#elif CONFIG_MUXERS && CONFIG_DEMUXERS
789
#define PCMDEF(name, long_name, ext, codec) \
790
        PCMINPUTDEF(name, long_name, ext, codec)\
791
        PCMOUTPUTDEF(name, long_name, ext, codec)
792
#else
793
#define PCMDEF(name, long_name, ext, codec)
794
#endif
795

    
796
#if HAVE_BIGENDIAN
797
#define BE_DEF(s) s
798
#define LE_DEF(s) NULL
799
#else
800
#define BE_DEF(s) NULL
801
#define LE_DEF(s) s
802
#endif
803

    
804
PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
805
       NULL, CODEC_ID_PCM_F64BE)
806

    
807
PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
808
       NULL, CODEC_ID_PCM_F64LE)
809

    
810
PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
811
       NULL, CODEC_ID_PCM_F32BE)
812

    
813
PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
814
       NULL, CODEC_ID_PCM_F32LE)
815

    
816
PCMDEF(s32be, "PCM signed 32 bit big-endian format",
817
       NULL, CODEC_ID_PCM_S32BE)
818

    
819
PCMDEF(s32le, "PCM signed 32 bit little-endian format",
820
       NULL, CODEC_ID_PCM_S32LE)
821

    
822
PCMDEF(s24be, "PCM signed 24 bit big-endian format",
823
       NULL, CODEC_ID_PCM_S24BE)
824

    
825
PCMDEF(s24le, "PCM signed 24 bit little-endian format",
826
       NULL, CODEC_ID_PCM_S24LE)
827

    
828
PCMDEF(s16be, "PCM signed 16 bit big-endian format",
829
       BE_DEF("sw"), CODEC_ID_PCM_S16BE)
830

    
831
PCMDEF(s16le, "PCM signed 16 bit little-endian format",
832
       LE_DEF("sw"), CODEC_ID_PCM_S16LE)
833

    
834
PCMDEF(s8, "PCM signed 8 bit format",
835
       "sb", CODEC_ID_PCM_S8)
836

    
837
PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
838
       NULL, CODEC_ID_PCM_U32BE)
839

    
840
PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
841
       NULL, CODEC_ID_PCM_U32LE)
842

    
843
PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
844
       NULL, CODEC_ID_PCM_U24BE)
845

    
846
PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
847
       NULL, CODEC_ID_PCM_U24LE)
848

    
849
PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
850
       BE_DEF("uw"), CODEC_ID_PCM_U16BE)
851

    
852
PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
853
       LE_DEF("uw"), CODEC_ID_PCM_U16LE)
854

    
855
PCMDEF(u8, "PCM unsigned 8 bit format",
856
       "ub", CODEC_ID_PCM_U8)
857

    
858
PCMDEF(alaw, "PCM A-law format",
859
       "al", CODEC_ID_PCM_ALAW)
860

    
861
PCMDEF(mulaw, "PCM mu-law format",
862
       "ul", CODEC_ID_PCM_MULAW)