Statistics
| Branch: | Revision:

ffmpeg / libavformat / raw.c @ ee7948cb

History | View | Annotate | Download (25.9 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/bitstream.h"
26
#include "libavcodec/bytestream.h"
27
#include "avformat.h"
28
#include "raw.h"
29

    
30
/* simple formats */
31
#ifdef CONFIG_FLAC_MUXER
32
static int flac_write_header(struct AVFormatContext *s)
33
{
34
    static const uint8_t header[8] = {
35
        0x66, 0x4C, 0x61, 0x43, 0x80, 0x00, 0x00, 0x22
36
    };
37
    uint8_t *streaminfo = s->streams[0]->codec->extradata;
38
    int len = s->streams[0]->codec->extradata_size;
39
    if(streaminfo != NULL && len > 0) {
40
        put_buffer(s->pb, header, 8);
41
        put_buffer(s->pb, streaminfo, len);
42
    }
43
    return 0;
44
}
45
#endif
46

    
47
#ifdef CONFIG_ROQ_MUXER
48
static int roq_write_header(struct AVFormatContext *s)
49
{
50
    static const uint8_t header[] = {
51
        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
52
    };
53

    
54
    put_buffer(s->pb, header, 8);
55
    put_flush_packet(s->pb);
56

    
57
    return 0;
58
}
59
#endif
60

    
61
#ifdef CONFIG_NULL_MUXER
62
static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
63
{
64
    return 0;
65
}
66
#endif
67

    
68
#ifdef CONFIG_MUXERS
69
static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
70
{
71
    put_buffer(s->pb, pkt->data, pkt->size);
72
    put_flush_packet(s->pb);
73
    return 0;
74
}
75
#endif
76

    
77
#ifdef CONFIG_DEMUXERS
78
/* raw input */
79
static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
80
{
81
    AVStream *st;
82
    int id;
83

    
84
    st = av_new_stream(s, 0);
85
    if (!st)
86
        return AVERROR(ENOMEM);
87

    
88
        id = s->iformat->value;
89
        if (id == CODEC_ID_RAWVIDEO) {
90
            st->codec->codec_type = CODEC_TYPE_VIDEO;
91
        } else {
92
            st->codec->codec_type = CODEC_TYPE_AUDIO;
93
        }
94
        st->codec->codec_id = id;
95

    
96
        switch(st->codec->codec_type) {
97
        case CODEC_TYPE_AUDIO:
98
            st->codec->sample_rate = ap->sample_rate;
99
            st->codec->channels = ap->channels;
100
            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
101
            break;
102
        case CODEC_TYPE_VIDEO:
103
            if(ap->time_base.num)
104
                av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
105
            else
106
                av_set_pts_info(st, 64, 1, 25);
107
            st->codec->width = ap->width;
108
            st->codec->height = ap->height;
109
            st->codec->pix_fmt = ap->pix_fmt;
110
            if(st->codec->pix_fmt == PIX_FMT_NONE)
111
                st->codec->pix_fmt= PIX_FMT_YUV420P;
112
            break;
113
        default:
114
            return -1;
115
        }
116
    return 0;
117
}
118

    
119
#define RAW_PACKET_SIZE 1024
120

    
121
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
122
{
123
    int ret, size, bps;
124
    //    AVStream *st = s->streams[0];
125

    
126
    size= RAW_PACKET_SIZE;
127

    
128
    ret= av_get_packet(s->pb, pkt, size);
129

    
130
    pkt->stream_index = 0;
131
    if (ret <= 0) {
132
        return AVERROR(EIO);
133
    }
134
    /* note: we need to modify the packet size here to handle the last
135
       packet */
136
    pkt->size = ret;
137

    
138
    bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
139
    assert(bps); // if false there IS a bug elsewhere (NOT in this function)
140
    pkt->dts=
141
    pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
142

    
143
    return ret;
144
}
145

    
146
static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
147
{
148
    int ret, size;
149

    
150
    size = RAW_PACKET_SIZE;
151

    
152
    if (av_new_packet(pkt, size) < 0)
153
        return AVERROR(EIO);
154

    
155
    pkt->pos= url_ftell(s->pb);
156
    pkt->stream_index = 0;
157
    ret = get_partial_buffer(s->pb, pkt->data, size);
158
    if (ret <= 0) {
159
        av_free_packet(pkt);
160
        return AVERROR(EIO);
161
    }
162
    pkt->size = ret;
163
    return ret;
164
}
165
#endif
166

    
167
#ifdef CONFIG_RAWVIDEO_DEMUXER
168
static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
169
{
170
    int packet_size, ret, width, height;
171
    AVStream *st = s->streams[0];
172

    
173
    width = st->codec->width;
174
    height = st->codec->height;
175

    
176
    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
177
    if (packet_size < 0)
178
        return -1;
179

    
180
    ret= av_get_packet(s->pb, pkt, packet_size);
181
    pkt->pts=
182
    pkt->dts= pkt->pos / packet_size;
183

    
184
    pkt->stream_index = 0;
185
    if (ret != packet_size) {
186
        return AVERROR(EIO);
187
    } else {
188
        return 0;
189
    }
190
}
191
#endif
192

    
193
#ifdef CONFIG_INGENIENT_DEMUXER
194
// http://www.artificis.hu/files/texts/ingenient.txt
195
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
196
{
197
    int ret, size, w, h, unk1, unk2;
198

    
199
    if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
200
        return AVERROR(EIO); // FIXME
201

    
202
    size = get_le32(s->pb);
203

    
204
    w = get_le16(s->pb);
205
    h = get_le16(s->pb);
206

    
207
    url_fskip(s->pb, 8); // zero + size (padded?)
208
    url_fskip(s->pb, 2);
209
    unk1 = get_le16(s->pb);
210
    unk2 = get_le16(s->pb);
211
    url_fskip(s->pb, 22); // ASCII timestamp
212

    
213
    av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
214
        size, w, h, unk1, unk2);
215

    
216
    if (av_new_packet(pkt, size) < 0)
217
        return AVERROR(EIO);
218

    
219
    pkt->pos = url_ftell(s->pb);
220
    pkt->stream_index = 0;
221
    ret = get_buffer(s->pb, pkt->data, size);
222
    if (ret <= 0) {
223
        av_free_packet(pkt);
224
        return AVERROR(EIO);
225
    }
226
    pkt->size = ret;
227
    return ret;
228
}
229
#endif
230

    
231
#ifdef CONFIG_DEMUXERS
232
int pcm_read_seek(AVFormatContext *s,
233
                  int stream_index, int64_t timestamp, int flags)
234
{
235
    AVStream *st;
236
    int block_align, byte_rate, ret;
237
    int64_t pos;
238

    
239
    st = s->streams[0];
240

    
241
    block_align = st->codec->block_align ? st->codec->block_align :
242
        (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
243
    byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
244
        block_align * st->codec->sample_rate;
245

    
246
    if (block_align <= 0 || byte_rate <= 0)
247
        return -1;
248

    
249
    /* compute the position by aligning it to block_align */
250
    pos = av_rescale_rnd(timestamp * byte_rate,
251
                         st->time_base.num,
252
                         st->time_base.den * (int64_t)block_align,
253
                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
254
    pos *= block_align;
255

    
256
    /* recompute exact position */
257
    st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
258
    if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
259
        return ret;
260
    return 0;
261
}
262

    
263
static int audio_read_header(AVFormatContext *s,
264
                             AVFormatParameters *ap)
265
{
266
    AVStream *st = av_new_stream(s, 0);
267
    if (!st)
268
        return AVERROR(ENOMEM);
269
    st->codec->codec_type = CODEC_TYPE_AUDIO;
270
    st->codec->codec_id = s->iformat->value;
271
    st->need_parsing = AVSTREAM_PARSE_FULL;
272
    /* the parameters will be extracted from the compressed bitstream */
273
    return 0;
274
}
275

    
276
/* MPEG-1/H.263 input */
277
static int video_read_header(AVFormatContext *s,
278
                             AVFormatParameters *ap)
279
{
280
    AVStream *st;
281

    
282
    st = av_new_stream(s, 0);
283
    if (!st)
284
        return AVERROR(ENOMEM);
285

    
286
    st->codec->codec_type = CODEC_TYPE_VIDEO;
287
    st->codec->codec_id = s->iformat->value;
288
    st->need_parsing = AVSTREAM_PARSE_FULL;
289

    
290
    /* for MJPEG, specify frame rate */
291
    /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
292
    if (ap->time_base.num) {
293
        av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
294
    } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
295
                st->codec->codec_id == CODEC_ID_MPEG4 ||
296
                st->codec->codec_id == CODEC_ID_DIRAC ||
297
                st->codec->codec_id == CODEC_ID_H264) {
298
        av_set_pts_info(st, 64, 1, 25);
299
    }
300

    
301
    return 0;
302
}
303
#endif
304

    
305
#ifdef CONFIG_MPEGVIDEO_DEMUXER
306
#define SEQ_START_CODE          0x000001b3
307
#define GOP_START_CODE          0x000001b8
308
#define PICTURE_START_CODE      0x00000100
309
#define SLICE_START_CODE        0x00000101
310
#define PACK_START_CODE         0x000001ba
311
#define VIDEO_ID                0x000001e0
312
#define AUDIO_ID                0x000001c0
313

    
314
static int mpegvideo_probe(AVProbeData *p)
315
{
316
    uint32_t code= -1;
317
    int pic=0, seq=0, slice=0, pspack=0, pes=0;
318
    int i;
319

    
320
    for(i=0; i<p->buf_size; i++){
321
        code = (code<<8) + p->buf[i];
322
        if ((code & 0xffffff00) == 0x100) {
323
            switch(code){
324
            case     SEQ_START_CODE:   seq++; break;
325
            case PICTURE_START_CODE:   pic++; break;
326
            case   SLICE_START_CODE: slice++; break;
327
            case    PACK_START_CODE: pspack++; break;
328
            }
329
            if     ((code & 0x1f0) == VIDEO_ID)   pes++;
330
            else if((code & 0x1e0) == AUDIO_ID)   pes++;
331
        }
332
    }
333
    if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
334
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
335
    return 0;
336
}
337
#endif
338

    
339
#ifdef CONFIG_M4V_DEMUXER
340
#define VISUAL_OBJECT_START_CODE       0x000001b5
341
#define VOP_START_CODE                 0x000001b6
342

    
343
static int mpeg4video_probe(AVProbeData *probe_packet)
344
{
345
    uint32_t temp_buffer= -1;
346
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
347
    int i;
348

    
349
    for(i=0; i<probe_packet->buf_size; i++){
350
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
351
        if ((temp_buffer & 0xffffff00) != 0x100)
352
            continue;
353

    
354
        if (temp_buffer == VOP_START_CODE)                         VOP++;
355
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
356
        else if (temp_buffer < 0x120)                              VO++;
357
        else if (temp_buffer < 0x130)                              VOL++;
358
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
359
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
360
    }
361

    
362
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
363
        return AVPROBE_SCORE_MAX/2;
364
    return 0;
365
}
366
#endif
367

    
368
#ifdef CONFIG_H264_DEMUXER
369
static int h264_probe(AVProbeData *p)
370
{
371
    uint32_t code= -1;
372
    int sps=0, pps=0, idr=0, res=0, sli=0;
373
    int i;
374

    
375
    for(i=0; i<p->buf_size; i++){
376
        code = (code<<8) + p->buf[i];
377
        if ((code & 0xffffff00) == 0x100) {
378
            int ref_idc= (code>>5)&3;
379
            int type   = code & 0x1F;
380
            static const int8_t ref_zero[32]={
381
                2, 0, 0, 0, 0,-1, 1,-1,
382
               -1, 1, 1, 1, 1,-1, 2, 2,
383
                2, 2, 2, 0, 2, 2, 2, 2,
384
                2, 2, 2, 2, 2, 2, 2, 2
385
            };
386

    
387
            if(code & 0x80) //forbidden bit
388
                return 0;
389

    
390
            if(ref_zero[type] == 1 && ref_idc)
391
                return 0;
392
            if(ref_zero[type] ==-1 && !ref_idc)
393
                return 0;
394
            if(ref_zero[type] == 2)
395
                res++;
396

    
397
            switch(type){
398
            case     1:   sli++; break;
399
            case     5:   idr++; break;
400
            case     7:
401
                if(p->buf[i+2]&0x0F)
402
                    return 0;
403
                sps++;
404
                break;
405
            case     8:   pps++; break;
406
            }
407
        }
408
    }
409
    if(sps && pps && (idr||sli>3) && res<(sps+pps+idr))
410
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
411
    return 0;
412
}
413
#endif
414

    
415
#ifdef CONFIG_H263_DEMUXER
416
static int h263_probe(AVProbeData *p)
417
{
418
    int code;
419
    const uint8_t *d;
420

    
421
    d = p->buf;
422
    code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
423
    if (code == 0x20) {
424
        return 50;
425
    }
426
    return 0;
427
}
428
#endif
429

    
430
#ifdef CONFIG_H261_DEMUXER
431
static int h261_probe(AVProbeData *p)
432
{
433
    int code;
434
    const uint8_t *d;
435

    
436
    d = p->buf;
437
    code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
438
    if (code == 0x10) {
439
        return 50;
440
    }
441
    return 0;
442
}
443
#endif
444

    
445
#ifdef CONFIG_DTS_DEMUXER
446
#define DCA_MARKER_14B_BE 0x1FFFE800
447
#define DCA_MARKER_14B_LE 0xFF1F00E8
448
#define DCA_MARKER_RAW_BE 0x7FFE8001
449
#define DCA_MARKER_RAW_LE 0xFE7F0180
450
static int dts_probe(AVProbeData *p)
451
{
452
    const uint8_t *buf, *bufp;
453
    uint32_t state = -1;
454

    
455
    buf = p->buf;
456

    
457
    for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
458
        bufp = buf;
459
        state = (state << 16) | bytestream_get_be16(&bufp);
460

    
461
        /* regular bitstream */
462
        if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
463
            return AVPROBE_SCORE_MAX/2+1;
464

    
465
        /* 14 bits big-endian bitstream */
466
        if (state == DCA_MARKER_14B_BE)
467
            if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
468
                return AVPROBE_SCORE_MAX/2+1;
469

    
470
        /* 14 bits little-endian bitstream */
471
        if (state == DCA_MARKER_14B_LE)
472
            if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
473
                return AVPROBE_SCORE_MAX/2+1;
474
    }
475

    
476
    return 0;
477
}
478
#endif
479

    
480
#ifdef CONFIG_DIRAC_DEMUXER
481
static int dirac_probe(AVProbeData *p)
482
{
483
    if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
484
        return AVPROBE_SCORE_MAX;
485
    else
486
        return 0;
487
}
488
#endif
489

    
490
#ifdef CONFIG_AC3_DEMUXER
491
static int ac3_probe(AVProbeData *p)
492
{
493
    int max_frames, first_frames = 0, frames;
494
    uint8_t *buf, *buf2, *end;
495
    AC3HeaderInfo hdr;
496
    GetBitContext gbc;
497

    
498
    max_frames = 0;
499
    buf = p->buf;
500
    end = buf + p->buf_size;
501

    
502
    for(; buf < end; buf++) {
503
        buf2 = buf;
504

    
505
        for(frames = 0; buf2 < end; frames++) {
506
            init_get_bits(&gbc, buf2, 54);
507
            if(ff_ac3_parse_header(&gbc, &hdr) < 0)
508
                break;
509
            if(buf2 + hdr.frame_size > end ||
510
               av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
511
                break;
512
            buf2 += hdr.frame_size;
513
        }
514
        max_frames = FFMAX(max_frames, frames);
515
        if(buf == p->buf)
516
            first_frames = frames;
517
    }
518
    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
519
    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
520
    else if(max_frames>=1) return 1;
521
    else                   return 0;
522
}
523
#endif
524

    
525
#ifdef CONFIG_FLAC_DEMUXER
526
static int flac_probe(AVProbeData *p)
527
{
528
    if(memcmp(p->buf, "fLaC", 4)) return 0;
529
    else                          return AVPROBE_SCORE_MAX / 2;
530
}
531
#endif
532

    
533

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

    
536
#ifdef CONFIG_AAC_DEMUXER
537
AVInputFormat aac_demuxer = {
538
    "aac",
539
    NULL_IF_CONFIG_SMALL("ADTS AAC"),
540
    0,
541
    NULL,
542
    audio_read_header,
543
    raw_read_partial_packet,
544
    .flags= AVFMT_GENERIC_INDEX,
545
    .extensions = "aac",
546
    .value = CODEC_ID_AAC,
547
};
548
#endif
549

    
550
#ifdef CONFIG_AC3_DEMUXER
551
AVInputFormat ac3_demuxer = {
552
    "ac3",
553
    NULL_IF_CONFIG_SMALL("raw AC-3"),
554
    0,
555
    ac3_probe,
556
    audio_read_header,
557
    raw_read_partial_packet,
558
    .flags= AVFMT_GENERIC_INDEX,
559
    .extensions = "ac3",
560
    .value = CODEC_ID_AC3,
561
};
562
#endif
563

    
564
#ifdef CONFIG_AC3_MUXER
565
AVOutputFormat ac3_muxer = {
566
    "ac3",
567
    NULL_IF_CONFIG_SMALL("raw AC-3"),
568
    "audio/x-ac3",
569
    "ac3",
570
    0,
571
    CODEC_ID_AC3,
572
    CODEC_ID_NONE,
573
    NULL,
574
    raw_write_packet,
575
    .flags= AVFMT_NOTIMESTAMPS,
576
};
577
#endif
578

    
579
#ifdef CONFIG_DIRAC_DEMUXER
580
AVInputFormat dirac_demuxer = {
581
    "dirac",
582
    NULL_IF_CONFIG_SMALL("raw Dirac"),
583
    0,
584
    dirac_probe,
585
    video_read_header,
586
    raw_read_partial_packet,
587
    .flags= AVFMT_GENERIC_INDEX,
588
    .value = CODEC_ID_DIRAC,
589
};
590
#endif
591

    
592
#ifdef CONFIG_DIRAC_MUXER
593
AVOutputFormat dirac_muxer = {
594
    "dirac",
595
    NULL_IF_CONFIG_SMALL("raw Dirac"),
596
    NULL,
597
    "drc",
598
    0,
599
    CODEC_ID_NONE,
600
    CODEC_ID_DIRAC,
601
    NULL,
602
    raw_write_packet,
603
    .flags= AVFMT_NOTIMESTAMPS,
604
};
605
#endif
606

    
607
#ifdef CONFIG_DTS_DEMUXER
608
AVInputFormat dts_demuxer = {
609
    "dts",
610
    NULL_IF_CONFIG_SMALL("raw DTS"),
611
    0,
612
    dts_probe,
613
    audio_read_header,
614
    raw_read_partial_packet,
615
    .flags= AVFMT_GENERIC_INDEX,
616
    .extensions = "dts",
617
    .value = CODEC_ID_DTS,
618
};
619
#endif
620

    
621
#ifdef CONFIG_DTS_MUXER
622
AVOutputFormat dts_muxer = {
623
    "dts",
624
    NULL_IF_CONFIG_SMALL("raw DTS"),
625
    "audio/x-dca",
626
    "dts",
627
    0,
628
    CODEC_ID_DTS,
629
    CODEC_ID_NONE,
630
    NULL,
631
    raw_write_packet,
632
    .flags= AVFMT_NOTIMESTAMPS,
633
};
634
#endif
635

    
636
#ifdef CONFIG_FLAC_DEMUXER
637
AVInputFormat flac_demuxer = {
638
    "flac",
639
    NULL_IF_CONFIG_SMALL("raw FLAC"),
640
    0,
641
    flac_probe,
642
    audio_read_header,
643
    raw_read_partial_packet,
644
    .flags= AVFMT_GENERIC_INDEX,
645
    .extensions = "flac",
646
    .value = CODEC_ID_FLAC,
647
};
648
#endif
649

    
650
#ifdef CONFIG_FLAC_MUXER
651
AVOutputFormat flac_muxer = {
652
    "flac",
653
    NULL_IF_CONFIG_SMALL("raw FLAC"),
654
    "audio/x-flac",
655
    "flac",
656
    0,
657
    CODEC_ID_FLAC,
658
    CODEC_ID_NONE,
659
    flac_write_header,
660
    raw_write_packet,
661
    .flags= AVFMT_NOTIMESTAMPS,
662
};
663
#endif
664

    
665
#ifdef CONFIG_GSM_DEMUXER
666
AVInputFormat gsm_demuxer = {
667
    "gsm",
668
    NULL_IF_CONFIG_SMALL("GSM"),
669
    0,
670
    NULL,
671
    audio_read_header,
672
    raw_read_partial_packet,
673
    .flags= AVFMT_GENERIC_INDEX,
674
    .extensions = "gsm",
675
    .value = CODEC_ID_GSM,
676
};
677
#endif
678

    
679
#ifdef CONFIG_H261_DEMUXER
680
AVInputFormat h261_demuxer = {
681
    "h261",
682
    NULL_IF_CONFIG_SMALL("raw H.261"),
683
    0,
684
    h261_probe,
685
    video_read_header,
686
    raw_read_partial_packet,
687
    .flags= AVFMT_GENERIC_INDEX,
688
    .extensions = "h261",
689
    .value = CODEC_ID_H261,
690
};
691
#endif
692

    
693
#ifdef CONFIG_H261_MUXER
694
AVOutputFormat h261_muxer = {
695
    "h261",
696
    NULL_IF_CONFIG_SMALL("raw H.261"),
697
    "video/x-h261",
698
    "h261",
699
    0,
700
    CODEC_ID_NONE,
701
    CODEC_ID_H261,
702
    NULL,
703
    raw_write_packet,
704
    .flags= AVFMT_NOTIMESTAMPS,
705
};
706
#endif
707

    
708
#ifdef CONFIG_H263_DEMUXER
709
AVInputFormat h263_demuxer = {
710
    "h263",
711
    NULL_IF_CONFIG_SMALL("raw H.263"),
712
    0,
713
    h263_probe,
714
    video_read_header,
715
    raw_read_partial_packet,
716
    .flags= AVFMT_GENERIC_INDEX,
717
//    .extensions = "h263", //FIXME remove after writing mpeg4_probe
718
    .value = CODEC_ID_H263,
719
};
720
#endif
721

    
722
#ifdef CONFIG_H263_MUXER
723
AVOutputFormat h263_muxer = {
724
    "h263",
725
    NULL_IF_CONFIG_SMALL("raw H.263"),
726
    "video/x-h263",
727
    "h263",
728
    0,
729
    CODEC_ID_NONE,
730
    CODEC_ID_H263,
731
    NULL,
732
    raw_write_packet,
733
    .flags= AVFMT_NOTIMESTAMPS,
734
};
735
#endif
736

    
737
#ifdef CONFIG_H264_DEMUXER
738
AVInputFormat h264_demuxer = {
739
    "h264",
740
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
741
    0,
742
    h264_probe,
743
    video_read_header,
744
    raw_read_partial_packet,
745
    .flags= AVFMT_GENERIC_INDEX,
746
    .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
747
    .value = CODEC_ID_H264,
748
};
749
#endif
750

    
751
#ifdef CONFIG_H264_MUXER
752
AVOutputFormat h264_muxer = {
753
    "h264",
754
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
755
    NULL,
756
    "h264",
757
    0,
758
    CODEC_ID_NONE,
759
    CODEC_ID_H264,
760
    NULL,
761
    raw_write_packet,
762
    .flags= AVFMT_NOTIMESTAMPS,
763
};
764
#endif
765

    
766
#ifdef CONFIG_INGENIENT_DEMUXER
767
AVInputFormat ingenient_demuxer = {
768
    "ingenient",
769
    NULL_IF_CONFIG_SMALL("Ingenient MJPEG"),
770
    0,
771
    NULL,
772
    video_read_header,
773
    ingenient_read_packet,
774
    .flags= AVFMT_GENERIC_INDEX,
775
    .extensions = "cgi", // FIXME
776
    .value = CODEC_ID_MJPEG,
777
};
778
#endif
779

    
780
#ifdef CONFIG_M4V_DEMUXER
781
AVInputFormat m4v_demuxer = {
782
    "m4v",
783
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
784
    0,
785
    mpeg4video_probe, /** probing for MPEG-4 data */
786
    video_read_header,
787
    raw_read_partial_packet,
788
    .flags= AVFMT_GENERIC_INDEX,
789
    .extensions = "m4v", //FIXME remove after writing mpeg4_probe
790
    .value = CODEC_ID_MPEG4,
791
};
792
#endif
793

    
794
#ifdef CONFIG_M4V_MUXER
795
AVOutputFormat m4v_muxer = {
796
    "m4v",
797
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
798
    NULL,
799
    "m4v",
800
    0,
801
    CODEC_ID_NONE,
802
    CODEC_ID_MPEG4,
803
    NULL,
804
    raw_write_packet,
805
    .flags= AVFMT_NOTIMESTAMPS,
806
};
807
#endif
808

    
809
#ifdef CONFIG_MJPEG_DEMUXER
810
AVInputFormat mjpeg_demuxer = {
811
    "mjpeg",
812
    NULL_IF_CONFIG_SMALL("MJPEG video"),
813
    0,
814
    NULL,
815
    video_read_header,
816
    raw_read_partial_packet,
817
    .flags= AVFMT_GENERIC_INDEX,
818
    .extensions = "mjpg,mjpeg",
819
    .value = CODEC_ID_MJPEG,
820
};
821
#endif
822

    
823
#ifdef CONFIG_MJPEG_MUXER
824
AVOutputFormat mjpeg_muxer = {
825
    "mjpeg",
826
    NULL_IF_CONFIG_SMALL("MJPEG video"),
827
    "video/x-mjpeg",
828
    "mjpg,mjpeg",
829
    0,
830
    CODEC_ID_NONE,
831
    CODEC_ID_MJPEG,
832
    NULL,
833
    raw_write_packet,
834
    .flags= AVFMT_NOTIMESTAMPS,
835
};
836
#endif
837

    
838
#ifdef CONFIG_MLP_DEMUXER
839
AVInputFormat mlp_demuxer = {
840
    "mlp",
841
    NULL_IF_CONFIG_SMALL("raw MLP"),
842
    0,
843
    NULL,
844
    audio_read_header,
845
    raw_read_partial_packet,
846
    .flags= AVFMT_GENERIC_INDEX,
847
    .extensions = "mlp",
848
    .value = CODEC_ID_MLP,
849
};
850
#endif
851

    
852
#ifdef CONFIG_MPEG1VIDEO_MUXER
853
AVOutputFormat mpeg1video_muxer = {
854
    "mpeg1video",
855
    NULL_IF_CONFIG_SMALL("MPEG video"),
856
    "video/x-mpeg",
857
    "mpg,mpeg,m1v",
858
    0,
859
    CODEC_ID_NONE,
860
    CODEC_ID_MPEG1VIDEO,
861
    NULL,
862
    raw_write_packet,
863
    .flags= AVFMT_NOTIMESTAMPS,
864
};
865
#endif
866

    
867
#ifdef CONFIG_MPEG2VIDEO_MUXER
868
AVOutputFormat mpeg2video_muxer = {
869
    "mpeg2video",
870
    NULL_IF_CONFIG_SMALL("MPEG-2 video"),
871
    NULL,
872
    "m2v",
873
    0,
874
    CODEC_ID_NONE,
875
    CODEC_ID_MPEG2VIDEO,
876
    NULL,
877
    raw_write_packet,
878
    .flags= AVFMT_NOTIMESTAMPS,
879
};
880
#endif
881

    
882
#ifdef CONFIG_MPEGVIDEO_DEMUXER
883
AVInputFormat mpegvideo_demuxer = {
884
    "mpegvideo",
885
    NULL_IF_CONFIG_SMALL("MPEG video"),
886
    0,
887
    mpegvideo_probe,
888
    video_read_header,
889
    raw_read_partial_packet,
890
    .flags= AVFMT_GENERIC_INDEX,
891
    .value = CODEC_ID_MPEG1VIDEO,
892
};
893
#endif
894

    
895
#ifdef CONFIG_NULL_MUXER
896
AVOutputFormat null_muxer = {
897
    "null",
898
    NULL_IF_CONFIG_SMALL("null video format"),
899
    NULL,
900
    NULL,
901
    0,
902
#ifdef WORDS_BIGENDIAN
903
    CODEC_ID_PCM_S16BE,
904
#else
905
    CODEC_ID_PCM_S16LE,
906
#endif
907
    CODEC_ID_RAWVIDEO,
908
    NULL,
909
    null_write_packet,
910
    .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
911
};
912
#endif
913

    
914
#ifdef CONFIG_RAWVIDEO_DEMUXER
915
AVInputFormat rawvideo_demuxer = {
916
    "rawvideo",
917
    NULL_IF_CONFIG_SMALL("raw video format"),
918
    0,
919
    NULL,
920
    raw_read_header,
921
    rawvideo_read_packet,
922
    .flags= AVFMT_GENERIC_INDEX,
923
    .extensions = "yuv,cif,qcif,rgb",
924
    .value = CODEC_ID_RAWVIDEO,
925
};
926
#endif
927

    
928
#ifdef CONFIG_RAWVIDEO_MUXER
929
AVOutputFormat rawvideo_muxer = {
930
    "rawvideo",
931
    NULL_IF_CONFIG_SMALL("raw video format"),
932
    NULL,
933
    "yuv,rgb",
934
    0,
935
    CODEC_ID_NONE,
936
    CODEC_ID_RAWVIDEO,
937
    NULL,
938
    raw_write_packet,
939
    .flags= AVFMT_NOTIMESTAMPS,
940
};
941
#endif
942

    
943
#ifdef CONFIG_ROQ_MUXER
944
AVOutputFormat roq_muxer =
945
{
946
    "RoQ",
947
    NULL_IF_CONFIG_SMALL("id RoQ format"),
948
    NULL,
949
    "roq",
950
    0,
951
    CODEC_ID_ROQ_DPCM,
952
    CODEC_ID_ROQ,
953
    roq_write_header,
954
    raw_write_packet,
955
};
956
#endif
957

    
958
#ifdef CONFIG_SHORTEN_DEMUXER
959
AVInputFormat shorten_demuxer = {
960
    "shn",
961
    NULL_IF_CONFIG_SMALL("raw Shorten"),
962
    0,
963
    NULL,
964
    audio_read_header,
965
    raw_read_partial_packet,
966
    .flags= AVFMT_GENERIC_INDEX,
967
    .extensions = "shn",
968
    .value = CODEC_ID_SHORTEN,
969
};
970
#endif
971

    
972
#ifdef CONFIG_VC1_DEMUXER
973
AVInputFormat vc1_demuxer = {
974
    "vc1",
975
    NULL_IF_CONFIG_SMALL("raw VC-1"),
976
    0,
977
    NULL /* vc1_probe */,
978
    video_read_header,
979
    raw_read_partial_packet,
980
    .extensions = "vc1",
981
    .value = CODEC_ID_VC1,
982
};
983
#endif
984

    
985
/* PCM formats */
986

    
987
#define PCMINPUTDEF(name, long_name, ext, codec) \
988
AVInputFormat pcm_ ## name ## _demuxer = {\
989
    #name,\
990
    NULL_IF_CONFIG_SMALL(long_name),\
991
    0,\
992
    NULL,\
993
    raw_read_header,\
994
    raw_read_packet,\
995
    NULL,\
996
    pcm_read_seek,\
997
    .flags= AVFMT_GENERIC_INDEX,\
998
    .extensions = ext,\
999
    .value = codec,\
1000
};
1001

    
1002
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
1003
AVOutputFormat pcm_ ## name ## _muxer = {\
1004
    #name,\
1005
    NULL_IF_CONFIG_SMALL(long_name),\
1006
    NULL,\
1007
    ext,\
1008
    0,\
1009
    codec,\
1010
    CODEC_ID_NONE,\
1011
    NULL,\
1012
    raw_write_packet,\
1013
    .flags= AVFMT_NOTIMESTAMPS,\
1014
};
1015

    
1016

    
1017
#if !defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
1018
#define PCMDEF(name, long_name, ext, codec) \
1019
        PCMINPUTDEF(name, long_name, ext, codec)
1020
#elif defined(CONFIG_MUXERS) && !defined(CONFIG_DEMUXERS)
1021
#define PCMDEF(name, long_name, ext, codec) \
1022
        PCMOUTPUTDEF(name, long_name, ext, codec)
1023
#elif defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
1024
#define PCMDEF(name, long_name, ext, codec) \
1025
        PCMINPUTDEF(name, long_name, ext, codec)\
1026
        PCMOUTPUTDEF(name, long_name, ext, codec)
1027
#else
1028
#define PCMDEF(name, long_name, ext, codec)
1029
#endif
1030

    
1031
#ifdef WORDS_BIGENDIAN
1032
#define BE_DEF(s) s
1033
#define LE_DEF(s) NULL
1034
#else
1035
#define BE_DEF(s) NULL
1036
#define LE_DEF(s) s
1037
#endif
1038

    
1039
PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
1040
       NULL, CODEC_ID_PCM_F64BE)
1041

    
1042
PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
1043
       NULL, CODEC_ID_PCM_F64LE)
1044

    
1045
PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
1046
       NULL, CODEC_ID_PCM_F32BE)
1047

    
1048
PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
1049
       NULL, CODEC_ID_PCM_F32LE)
1050

    
1051
PCMDEF(s32be, "PCM signed 32 bit big-endian format",
1052
       NULL, CODEC_ID_PCM_S32BE)
1053

    
1054
PCMDEF(s32le, "PCM signed 32 bit little-endian format",
1055
       NULL, CODEC_ID_PCM_S32LE)
1056

    
1057
PCMDEF(s24be, "PCM signed 24 bit big-endian format",
1058
       NULL, CODEC_ID_PCM_S24BE)
1059

    
1060
PCMDEF(s24le, "PCM signed 24 bit little-endian format",
1061
       NULL, CODEC_ID_PCM_S24LE)
1062

    
1063
PCMDEF(s16be, "PCM signed 16 bit big-endian format",
1064
       BE_DEF("sw"), CODEC_ID_PCM_S16BE)
1065

    
1066
PCMDEF(s16le, "PCM signed 16 bit little-endian format",
1067
       LE_DEF("sw"), CODEC_ID_PCM_S16LE)
1068

    
1069
PCMDEF(s8, "PCM signed 8 bit format",
1070
       "sb", CODEC_ID_PCM_S8)
1071

    
1072
PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
1073
       NULL, CODEC_ID_PCM_U32BE)
1074

    
1075
PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
1076
       NULL, CODEC_ID_PCM_U32LE)
1077

    
1078
PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
1079
       NULL, CODEC_ID_PCM_U24BE)
1080

    
1081
PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
1082
       NULL, CODEC_ID_PCM_U24LE)
1083

    
1084
PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
1085
       BE_DEF("uw"), CODEC_ID_PCM_U16BE)
1086

    
1087
PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
1088
       LE_DEF("uw"), CODEC_ID_PCM_U16LE)
1089

    
1090
PCMDEF(u8, "PCM unsigned 8 bit format",
1091
       "ub", CODEC_ID_PCM_U8)
1092

    
1093
PCMDEF(alaw, "PCM A-law format",
1094
       "al", CODEC_ID_PCM_ALAW)
1095

    
1096
PCMDEF(mulaw, "PCM mu-law format",
1097
       "ul", CODEC_ID_PCM_MULAW)