Statistics
| Branch: | Revision:

ffmpeg / libavformat / raw.c @ 96445426

History | View | Annotate | Download (23.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
/* raw input */
78
static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
79
{
80
    AVStream *st;
81
    int id;
82

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

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

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

    
118
#define RAW_PACKET_SIZE 1024
119

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

    
125
    size= RAW_PACKET_SIZE;
126

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

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

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

    
142
    return ret;
143
}
144

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

    
149
    size = RAW_PACKET_SIZE;
150

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

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

    
165
static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
166
{
167
    int packet_size, ret, width, height;
168
    AVStream *st = s->streams[0];
169

    
170
    width = st->codec->width;
171
    height = st->codec->height;
172

    
173
    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
174
    if (packet_size < 0)
175
        return -1;
176

    
177
    ret= av_get_packet(s->pb, pkt, packet_size);
178
    pkt->pts=
179
    pkt->dts= pkt->pos / packet_size;
180

    
181
    pkt->stream_index = 0;
182
    if (ret != packet_size) {
183
        return AVERROR(EIO);
184
    } else {
185
        return 0;
186
    }
187
}
188

    
189
// http://www.artificis.hu/files/texts/ingenient.txt
190
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
191
{
192
    int ret, size, w, h, unk1, unk2;
193

    
194
    if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
195
        return AVERROR(EIO); // FIXME
196

    
197
    size = get_le32(s->pb);
198

    
199
    w = get_le16(s->pb);
200
    h = get_le16(s->pb);
201

    
202
    url_fskip(s->pb, 8); // zero + size (padded?)
203
    url_fskip(s->pb, 2);
204
    unk1 = get_le16(s->pb);
205
    unk2 = get_le16(s->pb);
206
    url_fskip(s->pb, 22); // ASCII timestamp
207

    
208
    av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
209
        size, w, h, unk1, unk2);
210

    
211
    if (av_new_packet(pkt, size) < 0)
212
        return AVERROR(EIO);
213

    
214
    pkt->pos = url_ftell(s->pb);
215
    pkt->stream_index = 0;
216
    ret = get_buffer(s->pb, pkt->data, size);
217
    if (ret <= 0) {
218
        av_free_packet(pkt);
219
        return AVERROR(EIO);
220
    }
221
    pkt->size = ret;
222
    return ret;
223
}
224

    
225
int pcm_read_seek(AVFormatContext *s,
226
                  int stream_index, int64_t timestamp, int flags)
227
{
228
    AVStream *st;
229
    int block_align, byte_rate, ret;
230
    int64_t pos;
231

    
232
    st = s->streams[0];
233

    
234
    block_align = st->codec->block_align ? st->codec->block_align :
235
        (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
236
    byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
237
        block_align * st->codec->sample_rate;
238

    
239
    if (block_align <= 0 || byte_rate <= 0)
240
        return -1;
241

    
242
    /* compute the position by aligning it to block_align */
243
    pos = av_rescale_rnd(timestamp * byte_rate,
244
                         st->time_base.num,
245
                         st->time_base.den * (int64_t)block_align,
246
                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
247
    pos *= block_align;
248

    
249
    /* recompute exact position */
250
    st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
251
    if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
252
        return ret;
253
    return 0;
254
}
255

    
256
static int audio_read_header(AVFormatContext *s,
257
                             AVFormatParameters *ap)
258
{
259
    AVStream *st = av_new_stream(s, 0);
260
    if (!st)
261
        return AVERROR(ENOMEM);
262
    st->codec->codec_type = CODEC_TYPE_AUDIO;
263
    st->codec->codec_id = s->iformat->value;
264
    st->need_parsing = AVSTREAM_PARSE_FULL;
265
    /* the parameters will be extracted from the compressed bitstream */
266
    return 0;
267
}
268

    
269
/* MPEG-1/H.263 input */
270
static int video_read_header(AVFormatContext *s,
271
                             AVFormatParameters *ap)
272
{
273
    AVStream *st;
274

    
275
    st = av_new_stream(s, 0);
276
    if (!st)
277
        return AVERROR(ENOMEM);
278

    
279
    st->codec->codec_type = CODEC_TYPE_VIDEO;
280
    st->codec->codec_id = s->iformat->value;
281
    st->need_parsing = AVSTREAM_PARSE_FULL;
282

    
283
    /* for MJPEG, specify frame rate */
284
    /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
285
    if (ap->time_base.num) {
286
        av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
287
    } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
288
                st->codec->codec_id == CODEC_ID_MPEG4 ||
289
                st->codec->codec_id == CODEC_ID_DIRAC ||
290
                st->codec->codec_id == CODEC_ID_H264) {
291
        av_set_pts_info(st, 64, 1, 25);
292
    }
293

    
294
    return 0;
295
}
296

    
297
#define SEQ_START_CODE          0x000001b3
298
#define GOP_START_CODE          0x000001b8
299
#define PICTURE_START_CODE      0x00000100
300
#define SLICE_START_CODE        0x00000101
301
#define PACK_START_CODE         0x000001ba
302
#define VIDEO_ID                0x000001e0
303
#define AUDIO_ID                0x000001c0
304

    
305
static int mpegvideo_probe(AVProbeData *p)
306
{
307
    uint32_t code= -1;
308
    int pic=0, seq=0, slice=0, pspack=0, pes=0;
309
    int i;
310

    
311
    for(i=0; i<p->buf_size; i++){
312
        code = (code<<8) + p->buf[i];
313
        if ((code & 0xffffff00) == 0x100) {
314
            switch(code){
315
            case     SEQ_START_CODE:   seq++; break;
316
            case PICTURE_START_CODE:   pic++; break;
317
            case   SLICE_START_CODE: slice++; break;
318
            case    PACK_START_CODE: pspack++; break;
319
            }
320
            if     ((code & 0x1f0) == VIDEO_ID)   pes++;
321
            else if((code & 0x1e0) == AUDIO_ID)   pes++;
322
        }
323
    }
324
    if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
325
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
326
    return 0;
327
}
328

    
329
#define VISUAL_OBJECT_START_CODE       0x000001b5
330
#define VOP_START_CODE                 0x000001b6
331

    
332
static int mpeg4video_probe(AVProbeData *probe_packet)
333
{
334
    uint32_t temp_buffer= -1;
335
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
336
    int i;
337

    
338
    for(i=0; i<probe_packet->buf_size; i++){
339
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
340
        if ((temp_buffer & 0xffffff00) != 0x100)
341
            continue;
342

    
343
        if (temp_buffer == VOP_START_CODE)                         VOP++;
344
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
345
        else if (temp_buffer < 0x120)                              VO++;
346
        else if (temp_buffer < 0x130)                              VOL++;
347
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
348
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
349
    }
350

    
351
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
352
        return AVPROBE_SCORE_MAX/2;
353
    return 0;
354
}
355

    
356
static int h264_probe(AVProbeData *p)
357
{
358
    uint32_t code= -1;
359
    int sps=0, pps=0, idr=0, res=0, sli=0;
360
    int i;
361

    
362
    for(i=0; i<p->buf_size; i++){
363
        code = (code<<8) + p->buf[i];
364
        if ((code & 0xffffff00) == 0x100) {
365
            int ref_idc= (code>>5)&3;
366
            int type   = code & 0x1F;
367
            static const int8_t ref_zero[32]={
368
                2, 0, 0, 0, 0,-1, 1,-1,
369
               -1, 1, 1, 1, 1,-1, 2, 2,
370
                2, 2, 2, 0, 2, 2, 2, 2,
371
                2, 2, 2, 2, 2, 2, 2, 2
372
            };
373

    
374
            if(code & 0x80) //forbidden bit
375
                return 0;
376

    
377
            if(ref_zero[type] == 1 && ref_idc)
378
                return 0;
379
            if(ref_zero[type] ==-1 && !ref_idc)
380
                return 0;
381
            if(ref_zero[type] == 2)
382
                res++;
383

    
384
            switch(type){
385
            case     1:   sli++; break;
386
            case     5:   idr++; break;
387
            case     7:
388
                if(p->buf[i+2]&0x0F)
389
                    return 0;
390
                sps++;
391
                break;
392
            case     8:   pps++; break;
393
            }
394
        }
395
    }
396
    if(sps && pps && (idr||sli>3) && res<(sps+pps+idr))
397
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
398
    return 0;
399
}
400

    
401
static int h263_probe(AVProbeData *p)
402
{
403
    int code;
404
    const uint8_t *d;
405

    
406
    d = p->buf;
407
    code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
408
    if (code == 0x20) {
409
        return 50;
410
    }
411
    return 0;
412
}
413

    
414
static int h261_probe(AVProbeData *p)
415
{
416
    int code;
417
    const uint8_t *d;
418

    
419
    d = p->buf;
420
    code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
421
    if (code == 0x10) {
422
        return 50;
423
    }
424
    return 0;
425
}
426

    
427
#define DCA_MARKER_14B_BE 0x1FFFE800
428
#define DCA_MARKER_14B_LE 0xFF1F00E8
429
#define DCA_MARKER_RAW_BE 0x7FFE8001
430
#define DCA_MARKER_RAW_LE 0xFE7F0180
431
static int dts_probe(AVProbeData *p)
432
{
433
    const uint8_t *buf, *bufp;
434
    uint32_t state = -1;
435

    
436
    buf = p->buf;
437

    
438
    for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
439
        bufp = buf;
440
        state = (state << 16) | bytestream_get_be16(&bufp);
441

    
442
        /* regular bitstream */
443
        if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
444
            return AVPROBE_SCORE_MAX/2+1;
445

    
446
        /* 14 bits big-endian bitstream */
447
        if (state == DCA_MARKER_14B_BE)
448
            if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
449
                return AVPROBE_SCORE_MAX/2+1;
450

    
451
        /* 14 bits little-endian bitstream */
452
        if (state == DCA_MARKER_14B_LE)
453
            if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
454
                return AVPROBE_SCORE_MAX/2+1;
455
    }
456

    
457
    return 0;
458
}
459

    
460
static int dirac_probe(AVProbeData *p)
461
{
462
    if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
463
        return AVPROBE_SCORE_MAX;
464
    else
465
        return 0;
466
}
467

    
468
static int ac3_probe(AVProbeData *p)
469
{
470
    int max_frames, first_frames = 0, frames;
471
    uint8_t *buf, *buf2, *end;
472
    AC3HeaderInfo hdr;
473
    GetBitContext gbc;
474

    
475
    max_frames = 0;
476
    buf = p->buf;
477
    end = buf + p->buf_size;
478

    
479
    for(; buf < end; buf++) {
480
        buf2 = buf;
481

    
482
        for(frames = 0; buf2 < end; frames++) {
483
            init_get_bits(&gbc, buf2, 54);
484
            if(ff_ac3_parse_header(&gbc, &hdr) < 0)
485
                break;
486
            if(buf2 + hdr.frame_size > end ||
487
               av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
488
                break;
489
            buf2 += hdr.frame_size;
490
        }
491
        max_frames = FFMAX(max_frames, frames);
492
        if(buf == p->buf)
493
            first_frames = frames;
494
    }
495
    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
496
    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
497
    else if(max_frames>=1) return 1;
498
    else                   return 0;
499
}
500

    
501
static int flac_probe(AVProbeData *p)
502
{
503
    if(memcmp(p->buf, "fLaC", 4)) return 0;
504
    else                          return AVPROBE_SCORE_MAX / 2;
505
}
506

    
507

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

    
510
AVInputFormat aac_demuxer = {
511
    "aac",
512
    NULL_IF_CONFIG_SMALL("ADTS AAC"),
513
    0,
514
    NULL,
515
    audio_read_header,
516
    raw_read_partial_packet,
517
    .flags= AVFMT_GENERIC_INDEX,
518
    .extensions = "aac",
519
    .value = CODEC_ID_AAC,
520
};
521

    
522
#ifdef CONFIG_AC3_DEMUXER
523
AVInputFormat ac3_demuxer = {
524
    "ac3",
525
    NULL_IF_CONFIG_SMALL("raw AC-3"),
526
    0,
527
    ac3_probe,
528
    audio_read_header,
529
    raw_read_partial_packet,
530
    .flags= AVFMT_GENERIC_INDEX,
531
    .extensions = "ac3",
532
    .value = CODEC_ID_AC3,
533
};
534
#endif
535

    
536
#ifdef CONFIG_AC3_MUXER
537
AVOutputFormat ac3_muxer = {
538
    "ac3",
539
    NULL_IF_CONFIG_SMALL("raw AC-3"),
540
    "audio/x-ac3",
541
    "ac3",
542
    0,
543
    CODEC_ID_AC3,
544
    CODEC_ID_NONE,
545
    NULL,
546
    raw_write_packet,
547
    .flags= AVFMT_NOTIMESTAMPS,
548
};
549
#endif
550

    
551
AVInputFormat dirac_demuxer = {
552
    "dirac",
553
    NULL_IF_CONFIG_SMALL("raw Dirac"),
554
    0,
555
    dirac_probe,
556
    video_read_header,
557
    raw_read_partial_packet,
558
    .flags= AVFMT_GENERIC_INDEX,
559
    .value = CODEC_ID_DIRAC,
560
};
561

    
562
#ifdef CONFIG_DIRAC_MUXER
563
AVOutputFormat dirac_muxer = {
564
    "dirac",
565
    NULL_IF_CONFIG_SMALL("raw Dirac"),
566
    NULL,
567
    "drc",
568
    0,
569
    CODEC_ID_NONE,
570
    CODEC_ID_DIRAC,
571
    NULL,
572
    raw_write_packet,
573
    .flags= AVFMT_NOTIMESTAMPS,
574
};
575
#endif
576

    
577
AVInputFormat dts_demuxer = {
578
    "dts",
579
    NULL_IF_CONFIG_SMALL("raw DTS"),
580
    0,
581
    dts_probe,
582
    audio_read_header,
583
    raw_read_partial_packet,
584
    .flags= AVFMT_GENERIC_INDEX,
585
    .extensions = "dts",
586
    .value = CODEC_ID_DTS,
587
};
588

    
589
#ifdef CONFIG_DTS_MUXER
590
AVOutputFormat dts_muxer = {
591
    "dts",
592
    NULL_IF_CONFIG_SMALL("raw DTS"),
593
    "audio/x-dca",
594
    "dts",
595
    0,
596
    CODEC_ID_DTS,
597
    CODEC_ID_NONE,
598
    NULL,
599
    raw_write_packet,
600
    .flags= AVFMT_NOTIMESTAMPS,
601
};
602
#endif
603

    
604
AVInputFormat flac_demuxer = {
605
    "flac",
606
    NULL_IF_CONFIG_SMALL("raw FLAC"),
607
    0,
608
    flac_probe,
609
    audio_read_header,
610
    raw_read_partial_packet,
611
    .flags= AVFMT_GENERIC_INDEX,
612
    .extensions = "flac",
613
    .value = CODEC_ID_FLAC,
614
};
615

    
616
#ifdef CONFIG_FLAC_MUXER
617
AVOutputFormat flac_muxer = {
618
    "flac",
619
    NULL_IF_CONFIG_SMALL("raw FLAC"),
620
    "audio/x-flac",
621
    "flac",
622
    0,
623
    CODEC_ID_FLAC,
624
    CODEC_ID_NONE,
625
    flac_write_header,
626
    raw_write_packet,
627
    .flags= AVFMT_NOTIMESTAMPS,
628
};
629
#endif
630

    
631
AVInputFormat gsm_demuxer = {
632
    "gsm",
633
    NULL_IF_CONFIG_SMALL("GSM"),
634
    0,
635
    NULL,
636
    audio_read_header,
637
    raw_read_partial_packet,
638
    .flags= AVFMT_GENERIC_INDEX,
639
    .extensions = "gsm",
640
    .value = CODEC_ID_GSM,
641
};
642

    
643
AVInputFormat h261_demuxer = {
644
    "h261",
645
    NULL_IF_CONFIG_SMALL("raw H.261"),
646
    0,
647
    h261_probe,
648
    video_read_header,
649
    raw_read_partial_packet,
650
    .flags= AVFMT_GENERIC_INDEX,
651
    .extensions = "h261",
652
    .value = CODEC_ID_H261,
653
};
654

    
655
#ifdef CONFIG_H261_MUXER
656
AVOutputFormat h261_muxer = {
657
    "h261",
658
    NULL_IF_CONFIG_SMALL("raw H.261"),
659
    "video/x-h261",
660
    "h261",
661
    0,
662
    CODEC_ID_NONE,
663
    CODEC_ID_H261,
664
    NULL,
665
    raw_write_packet,
666
    .flags= AVFMT_NOTIMESTAMPS,
667
};
668
#endif
669

    
670
AVInputFormat h263_demuxer = {
671
    "h263",
672
    NULL_IF_CONFIG_SMALL("raw H.263"),
673
    0,
674
    h263_probe,
675
    video_read_header,
676
    raw_read_partial_packet,
677
    .flags= AVFMT_GENERIC_INDEX,
678
//    .extensions = "h263", //FIXME remove after writing mpeg4_probe
679
    .value = CODEC_ID_H263,
680
};
681

    
682
#ifdef CONFIG_H263_MUXER
683
AVOutputFormat h263_muxer = {
684
    "h263",
685
    NULL_IF_CONFIG_SMALL("raw H.263"),
686
    "video/x-h263",
687
    "h263",
688
    0,
689
    CODEC_ID_NONE,
690
    CODEC_ID_H263,
691
    NULL,
692
    raw_write_packet,
693
    .flags= AVFMT_NOTIMESTAMPS,
694
};
695
#endif
696

    
697
AVInputFormat h264_demuxer = {
698
    "h264",
699
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
700
    0,
701
    h264_probe,
702
    video_read_header,
703
    raw_read_partial_packet,
704
    .flags= AVFMT_GENERIC_INDEX,
705
    .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
706
    .value = CODEC_ID_H264,
707
};
708

    
709
#ifdef CONFIG_H264_MUXER
710
AVOutputFormat h264_muxer = {
711
    "h264",
712
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
713
    NULL,
714
    "h264",
715
    0,
716
    CODEC_ID_NONE,
717
    CODEC_ID_H264,
718
    NULL,
719
    raw_write_packet,
720
    .flags= AVFMT_NOTIMESTAMPS,
721
};
722
#endif
723

    
724
AVInputFormat ingenient_demuxer = {
725
    "ingenient",
726
    NULL_IF_CONFIG_SMALL("Ingenient MJPEG"),
727
    0,
728
    NULL,
729
    video_read_header,
730
    ingenient_read_packet,
731
    .flags= AVFMT_GENERIC_INDEX,
732
    .extensions = "cgi", // FIXME
733
    .value = CODEC_ID_MJPEG,
734
};
735

    
736
AVInputFormat m4v_demuxer = {
737
    "m4v",
738
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
739
    0,
740
    mpeg4video_probe, /** probing for MPEG-4 data */
741
    video_read_header,
742
    raw_read_partial_packet,
743
    .flags= AVFMT_GENERIC_INDEX,
744
    .extensions = "m4v", //FIXME remove after writing mpeg4_probe
745
    .value = CODEC_ID_MPEG4,
746
};
747

    
748
#ifdef CONFIG_M4V_MUXER
749
AVOutputFormat m4v_muxer = {
750
    "m4v",
751
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
752
    NULL,
753
    "m4v",
754
    0,
755
    CODEC_ID_NONE,
756
    CODEC_ID_MPEG4,
757
    NULL,
758
    raw_write_packet,
759
    .flags= AVFMT_NOTIMESTAMPS,
760
};
761
#endif
762

    
763
AVInputFormat mjpeg_demuxer = {
764
    "mjpeg",
765
    NULL_IF_CONFIG_SMALL("MJPEG video"),
766
    0,
767
    NULL,
768
    video_read_header,
769
    raw_read_partial_packet,
770
    .flags= AVFMT_GENERIC_INDEX,
771
    .extensions = "mjpg,mjpeg",
772
    .value = CODEC_ID_MJPEG,
773
};
774

    
775
#ifdef CONFIG_MJPEG_MUXER
776
AVOutputFormat mjpeg_muxer = {
777
    "mjpeg",
778
    NULL_IF_CONFIG_SMALL("MJPEG video"),
779
    "video/x-mjpeg",
780
    "mjpg,mjpeg",
781
    0,
782
    CODEC_ID_NONE,
783
    CODEC_ID_MJPEG,
784
    NULL,
785
    raw_write_packet,
786
    .flags= AVFMT_NOTIMESTAMPS,
787
};
788
#endif
789

    
790
AVInputFormat mlp_demuxer = {
791
    "mlp",
792
    NULL_IF_CONFIG_SMALL("raw MLP"),
793
    0,
794
    NULL,
795
    audio_read_header,
796
    raw_read_partial_packet,
797
    .flags= AVFMT_GENERIC_INDEX,
798
    .extensions = "mlp",
799
    .value = CODEC_ID_MLP,
800
};
801

    
802
#ifdef CONFIG_MPEG1VIDEO_MUXER
803
AVOutputFormat mpeg1video_muxer = {
804
    "mpeg1video",
805
    NULL_IF_CONFIG_SMALL("MPEG video"),
806
    "video/x-mpeg",
807
    "mpg,mpeg,m1v",
808
    0,
809
    CODEC_ID_NONE,
810
    CODEC_ID_MPEG1VIDEO,
811
    NULL,
812
    raw_write_packet,
813
    .flags= AVFMT_NOTIMESTAMPS,
814
};
815
#endif
816

    
817
#ifdef CONFIG_MPEG2VIDEO_MUXER
818
AVOutputFormat mpeg2video_muxer = {
819
    "mpeg2video",
820
    NULL_IF_CONFIG_SMALL("MPEG-2 video"),
821
    NULL,
822
    "m2v",
823
    0,
824
    CODEC_ID_NONE,
825
    CODEC_ID_MPEG2VIDEO,
826
    NULL,
827
    raw_write_packet,
828
    .flags= AVFMT_NOTIMESTAMPS,
829
};
830
#endif
831

    
832
AVInputFormat mpegvideo_demuxer = {
833
    "mpegvideo",
834
    NULL_IF_CONFIG_SMALL("MPEG video"),
835
    0,
836
    mpegvideo_probe,
837
    video_read_header,
838
    raw_read_partial_packet,
839
    .flags= AVFMT_GENERIC_INDEX,
840
    .value = CODEC_ID_MPEG1VIDEO,
841
};
842

    
843
#ifdef CONFIG_NULL_MUXER
844
AVOutputFormat null_muxer = {
845
    "null",
846
    NULL_IF_CONFIG_SMALL("null video format"),
847
    NULL,
848
    NULL,
849
    0,
850
#ifdef WORDS_BIGENDIAN
851
    CODEC_ID_PCM_S16BE,
852
#else
853
    CODEC_ID_PCM_S16LE,
854
#endif
855
    CODEC_ID_RAWVIDEO,
856
    NULL,
857
    null_write_packet,
858
    .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
859
};
860
#endif
861

    
862
AVInputFormat rawvideo_demuxer = {
863
    "rawvideo",
864
    NULL_IF_CONFIG_SMALL("raw video format"),
865
    0,
866
    NULL,
867
    raw_read_header,
868
    rawvideo_read_packet,
869
    .flags= AVFMT_GENERIC_INDEX,
870
    .extensions = "yuv,cif,qcif,rgb",
871
    .value = CODEC_ID_RAWVIDEO,
872
};
873

    
874
#ifdef CONFIG_RAWVIDEO_MUXER
875
AVOutputFormat rawvideo_muxer = {
876
    "rawvideo",
877
    NULL_IF_CONFIG_SMALL("raw video format"),
878
    NULL,
879
    "yuv,rgb",
880
    0,
881
    CODEC_ID_NONE,
882
    CODEC_ID_RAWVIDEO,
883
    NULL,
884
    raw_write_packet,
885
    .flags= AVFMT_NOTIMESTAMPS,
886
};
887
#endif
888

    
889
#ifdef CONFIG_ROQ_MUXER
890
AVOutputFormat roq_muxer =
891
{
892
    "RoQ",
893
    NULL_IF_CONFIG_SMALL("id RoQ format"),
894
    NULL,
895
    "roq",
896
    0,
897
    CODEC_ID_ROQ_DPCM,
898
    CODEC_ID_ROQ,
899
    roq_write_header,
900
    raw_write_packet,
901
};
902
#endif
903

    
904
AVInputFormat shorten_demuxer = {
905
    "shn",
906
    NULL_IF_CONFIG_SMALL("raw Shorten"),
907
    0,
908
    NULL,
909
    audio_read_header,
910
    raw_read_partial_packet,
911
    .flags= AVFMT_GENERIC_INDEX,
912
    .extensions = "shn",
913
    .value = CODEC_ID_SHORTEN,
914
};
915

    
916
AVInputFormat vc1_demuxer = {
917
    "vc1",
918
    NULL_IF_CONFIG_SMALL("raw VC-1"),
919
    0,
920
    NULL /* vc1_probe */,
921
    video_read_header,
922
    raw_read_partial_packet,
923
    .extensions = "vc1",
924
    .value = CODEC_ID_VC1,
925
};
926

    
927
/* PCM formats */
928

    
929
#define PCMINPUTDEF(name, long_name, ext, codec) \
930
AVInputFormat pcm_ ## name ## _demuxer = {\
931
    #name,\
932
    NULL_IF_CONFIG_SMALL(long_name),\
933
    0,\
934
    NULL,\
935
    raw_read_header,\
936
    raw_read_packet,\
937
    NULL,\
938
    pcm_read_seek,\
939
    .flags= AVFMT_GENERIC_INDEX,\
940
    .extensions = ext,\
941
    .value = codec,\
942
};
943

    
944
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
945
AVOutputFormat pcm_ ## name ## _muxer = {\
946
    #name,\
947
    NULL_IF_CONFIG_SMALL(long_name),\
948
    NULL,\
949
    ext,\
950
    0,\
951
    codec,\
952
    CODEC_ID_NONE,\
953
    NULL,\
954
    raw_write_packet,\
955
    .flags= AVFMT_NOTIMESTAMPS,\
956
};
957

    
958

    
959
#if !defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
960
#define PCMDEF(name, long_name, ext, codec) \
961
        PCMINPUTDEF(name, long_name, ext, codec)
962
#elif defined(CONFIG_MUXERS) && !defined(CONFIG_DEMUXERS)
963
#define PCMDEF(name, long_name, ext, codec) \
964
        PCMOUTPUTDEF(name, long_name, ext, codec)
965
#elif defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
966
#define PCMDEF(name, long_name, ext, codec) \
967
        PCMINPUTDEF(name, long_name, ext, codec)\
968
        PCMOUTPUTDEF(name, long_name, ext, codec)
969
#else
970
#define PCMDEF(name, long_name, ext, codec)
971
#endif
972

    
973
#ifdef WORDS_BIGENDIAN
974
#define BE_DEF(s) s
975
#define LE_DEF(s) NULL
976
#else
977
#define BE_DEF(s) NULL
978
#define LE_DEF(s) s
979
#endif
980

    
981

    
982
PCMDEF(s16be, "PCM signed 16 bit big-endian format",
983
       BE_DEF("sw"), CODEC_ID_PCM_S16BE)
984

    
985
PCMDEF(s16le, "PCM signed 16 bit little-endian format",
986
       LE_DEF("sw"), CODEC_ID_PCM_S16LE)
987

    
988
PCMDEF(s8, "PCM signed 8 bit format",
989
       "sb", CODEC_ID_PCM_S8)
990

    
991
PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
992
       BE_DEF("uw"), CODEC_ID_PCM_U16BE)
993

    
994
PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
995
       LE_DEF("uw"), CODEC_ID_PCM_U16LE)
996

    
997
PCMDEF(u8, "PCM unsigned 8 bit format",
998
       "ub", CODEC_ID_PCM_U8)
999

    
1000
PCMDEF(alaw, "PCM A-law format",
1001
       "al", CODEC_ID_PCM_ALAW)
1002

    
1003
PCMDEF(mulaw, "PCM mu-law format",
1004
       "ul", CODEC_ID_PCM_MULAW)