raw.c 20.3 KB
Newer Older
1
/*
2
 * RAW muxer and demuxer
Fabrice Bellard's avatar
Fabrice Bellard committed
3
 * Copyright (c) 2001 Fabrice Bellard.
4
 * Copyright (c) 2005 Alex Beregszaszi
Fabrice Bellard's avatar
Fabrice Bellard committed
5
 *
6 7 8
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
Fabrice Bellard's avatar
Fabrice Bellard committed
9 10
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
Fabrice Bellard's avatar
Fabrice Bellard committed
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
Fabrice Bellard's avatar
Fabrice Bellard committed
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Fabrice Bellard's avatar
Fabrice Bellard committed
15 16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
Fabrice Bellard's avatar
Fabrice Bellard committed
17
 *
Fabrice Bellard's avatar
Fabrice Bellard committed
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
Fabrice Bellard's avatar
Fabrice Bellard committed
21 22
 */
#include "avformat.h"
23
#include "ac3_parser.h"
24
#include "raw.h"
25
#include "crc.h"
26
#include "bitstream.h"
Fabrice Bellard's avatar
Fabrice Bellard committed
27

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

44 45 46 47 48 49 50

static int roq_write_header(struct AVFormatContext *s)
{
    static const uint8_t header[] = {
        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
    };

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

    return 0;
}

57
static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
Fabrice Bellard's avatar
Fabrice Bellard committed
58
{
59 60
    put_buffer(s->pb, pkt->data, pkt->size);
    put_flush_packet(s->pb);
Fabrice Bellard's avatar
Fabrice Bellard committed
61 62
    return 0;
}
63
#endif //CONFIG_MUXERS
Fabrice Bellard's avatar
Fabrice Bellard committed
64 65

/* raw input */
66
static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
Fabrice Bellard's avatar
Fabrice Bellard committed
67 68
{
    AVStream *st;
Fabrice Bellard's avatar
Fabrice Bellard committed
69
    int id;
Fabrice Bellard's avatar
Fabrice Bellard committed
70

Fabrice Bellard's avatar
Fabrice Bellard committed
71
    st = av_new_stream(s, 0);
Fabrice Bellard's avatar
Fabrice Bellard committed
72
    if (!st)
73
        return AVERROR(ENOMEM);
74

Fabrice Bellard's avatar
Fabrice Bellard committed
75 76
        id = s->iformat->value;
        if (id == CODEC_ID_RAWVIDEO) {
77
            st->codec->codec_type = CODEC_TYPE_VIDEO;
Fabrice Bellard's avatar
Fabrice Bellard committed
78
        } else {
79
            st->codec->codec_type = CODEC_TYPE_AUDIO;
Fabrice Bellard's avatar
Fabrice Bellard committed
80
        }
81
        st->codec->codec_id = id;
Fabrice Bellard's avatar
Fabrice Bellard committed
82

83
        switch(st->codec->codec_type) {
Fabrice Bellard's avatar
Fabrice Bellard committed
84
        case CODEC_TYPE_AUDIO:
85 86 87
            st->codec->sample_rate = ap->sample_rate;
            st->codec->channels = ap->channels;
            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
Fabrice Bellard's avatar
Fabrice Bellard committed
88 89
            break;
        case CODEC_TYPE_VIDEO:
90 91 92 93
            if(ap->time_base.num)
                av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
            else
                av_set_pts_info(st, 64, 1, 25);
94 95 96 97 98
            st->codec->width = ap->width;
            st->codec->height = ap->height;
            st->codec->pix_fmt = ap->pix_fmt;
            if(st->codec->pix_fmt == PIX_FMT_NONE)
                st->codec->pix_fmt= PIX_FMT_YUV420P;
Fabrice Bellard's avatar
Fabrice Bellard committed
99 100
            break;
        default:
Fabrice Bellard's avatar
Fabrice Bellard committed
101
            return -1;
Fabrice Bellard's avatar
Fabrice Bellard committed
102 103 104 105
        }
    return 0;
}

Fabrice Bellard's avatar
Fabrice Bellard committed
106
#define RAW_PACKET_SIZE 1024
Fabrice Bellard's avatar
Fabrice Bellard committed
107

108
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
Fabrice Bellard's avatar
Fabrice Bellard committed
109
{
110
    int ret, size, bps;
Fabrice Bellard's avatar
Fabrice Bellard committed
111
    //    AVStream *st = s->streams[0];
112

113
    size= RAW_PACKET_SIZE;
Fabrice Bellard's avatar
Fabrice Bellard committed
114

115
    ret= av_get_packet(s->pb, pkt, size);
Fabrice Bellard's avatar
Fabrice Bellard committed
116 117

    pkt->stream_index = 0;
Fabrice Bellard's avatar
Fabrice Bellard committed
118
    if (ret <= 0) {
119
        return AVERROR(EIO);
Fabrice Bellard's avatar
Fabrice Bellard committed
120 121 122 123
    }
    /* note: we need to modify the packet size here to handle the last
       packet */
    pkt->size = ret;
124 125 126 127 128 129

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

Fabrice Bellard's avatar
Fabrice Bellard committed
130 131 132
    return ret;
}

133 134 135 136 137 138 139
static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
{
    int ret, size;

    size = RAW_PACKET_SIZE;

    if (av_new_packet(pkt, size) < 0)
140
        return AVERROR(EIO);
141

142
    pkt->pos= url_ftell(s->pb);
143
    pkt->stream_index = 0;
144
    ret = get_partial_buffer(s->pb, pkt->data, size);
145 146
    if (ret <= 0) {
        av_free_packet(pkt);
147
        return AVERROR(EIO);
148 149 150 151 152
    }
    pkt->size = ret;
    return ret;
}

153 154 155 156
// http://www.artificis.hu/files/texts/ingenient.txt
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
{
    int ret, size, w, h, unk1, unk2;
157

158
    if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
159
        return AVERROR(EIO); // FIXME
160

161
    size = get_le32(s->pb);
162

163 164
    w = get_le16(s->pb);
    h = get_le16(s->pb);
165

166 167 168 169 170
    url_fskip(s->pb, 8); // zero + size (padded?)
    url_fskip(s->pb, 2);
    unk1 = get_le16(s->pb);
    unk2 = get_le16(s->pb);
    url_fskip(s->pb, 22); // ascii timestamp
171

172
    av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
173
        size, w, h, unk1, unk2);
174 175

    if (av_new_packet(pkt, size) < 0)
176
        return AVERROR(EIO);
177

178
    pkt->pos = url_ftell(s->pb);
179
    pkt->stream_index = 0;
180
    ret = get_buffer(s->pb, pkt->data, size);
181 182
    if (ret <= 0) {
        av_free_packet(pkt);
183
        return AVERROR(EIO);
184 185 186 187 188
    }
    pkt->size = ret;
    return ret;
}

189
static int raw_read_close(AVFormatContext *s)
Fabrice Bellard's avatar
Fabrice Bellard committed
190 191 192 193
{
    return 0;
}

194
int pcm_read_seek(AVFormatContext *s,
195
                  int stream_index, int64_t timestamp, int flags)
Fabrice Bellard's avatar
Fabrice Bellard committed
196 197 198 199 200 201
{
    AVStream *st;
    int block_align, byte_rate;
    int64_t pos;

    st = s->streams[0];
202 203 204 205 206

    block_align = st->codec->block_align ? st->codec->block_align :
        (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
    byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
        block_align * st->codec->sample_rate;
207

Fabrice Bellard's avatar
Fabrice Bellard committed
208 209 210 211
    if (block_align <= 0 || byte_rate <= 0)
        return -1;

    /* compute the position by aligning it to block_align */
212 213
    pos = av_rescale_rnd(timestamp * byte_rate,
                         st->time_base.num,
214 215 216
                         st->time_base.den * (int64_t)block_align,
                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
    pos *= block_align;
Fabrice Bellard's avatar
Fabrice Bellard committed
217 218

    /* recompute exact position */
219
    st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
220
    url_fseek(s->pb, pos + s->data_offset, SEEK_SET);
Fabrice Bellard's avatar
Fabrice Bellard committed
221 222 223
    return 0;
}

224 225
static int audio_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
Måns Rullgård's avatar
Måns Rullgård committed
226
{
227
    AVStream *st = av_new_stream(s, 0);
Måns Rullgård's avatar
Måns Rullgård committed
228
    if (!st)
229
        return AVERROR(ENOMEM);
Måns Rullgård's avatar
Måns Rullgård committed
230
    st->codec->codec_type = CODEC_TYPE_AUDIO;
231
    st->codec->codec_id = s->iformat->value;
Aurelien Jacobs's avatar
Aurelien Jacobs committed
232
    st->need_parsing = AVSTREAM_PARSE_FULL;
Måns Rullgård's avatar
Måns Rullgård committed
233 234 235 236
    /* the parameters will be extracted from the compressed bitstream */
    return 0;
}

Fabrice Bellard's avatar
Fabrice Bellard committed
237 238 239 240 241 242
/* mpeg1/h263 input */
static int video_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
{
    AVStream *st;

Fabrice Bellard's avatar
Fabrice Bellard committed
243
    st = av_new_stream(s, 0);
Fabrice Bellard's avatar
Fabrice Bellard committed
244
    if (!st)
245
        return AVERROR(ENOMEM);
Fabrice Bellard's avatar
Fabrice Bellard committed
246

247 248
    st->codec->codec_type = CODEC_TYPE_VIDEO;
    st->codec->codec_id = s->iformat->value;
Aurelien Jacobs's avatar
Aurelien Jacobs committed
249
    st->need_parsing = AVSTREAM_PARSE_FULL;
Fabrice Bellard's avatar
Fabrice Bellard committed
250

Fabrice Bellard's avatar
Fabrice Bellard committed
251
    /* for mjpeg, specify frame rate */
Diego Biurrun's avatar
Diego Biurrun committed
252
    /* for mpeg4 specify it too (most mpeg4 streams do not have the fixed_vop_rate set ...)*/
253
    if (ap->time_base.num) {
254
        av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
255
    } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
256 257
                st->codec->codec_id == CODEC_ID_MPEG4 ||
                st->codec->codec_id == CODEC_ID_H264) {
258
        av_set_pts_info(st, 64, 1, 25);
Fabrice Bellard's avatar
Fabrice Bellard committed
259
    }
260

Fabrice Bellard's avatar
Fabrice Bellard committed
261 262 263
    return 0;
}

264 265 266
#define SEQ_START_CODE          0x000001b3
#define GOP_START_CODE          0x000001b8
#define PICTURE_START_CODE      0x00000100
267 268
#define SLICE_START_CODE        0x00000101
#define PACK_START_CODE         0x000001ba
269 270
#define VIDEO_ID                0x000001e0
#define AUDIO_ID                0x000001c0
Fabrice Bellard's avatar
Fabrice Bellard committed
271 272 273

static int mpegvideo_probe(AVProbeData *p)
{
274
    uint32_t code= -1;
275
    int pic=0, seq=0, slice=0, pspack=0, pes=0;
276 277 278 279 280 281 282 283 284 285 286
    int i;

    for(i=0; i<p->buf_size; i++){
        code = (code<<8) + p->buf[i];
        if ((code & 0xffffff00) == 0x100) {
            switch(code){
            case     SEQ_START_CODE:   seq++; break;
            case PICTURE_START_CODE:   pic++; break;
            case   SLICE_START_CODE: slice++; break;
            case    PACK_START_CODE: pspack++; break;
            }
287 288
            if     ((code & 0x1f0) == VIDEO_ID)   pes++;
            else if((code & 0x1e0) == AUDIO_ID)   pes++;
289
        }
Fabrice Bellard's avatar
Fabrice Bellard committed
290
    }
291
    if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
292
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
Fabrice Bellard's avatar
Fabrice Bellard committed
293 294 295
    return 0;
}

296 297 298 299 300 301
#define VISUAL_OBJECT_START_CODE       0x000001b5
#define VOP_START_CODE                 0x000001b6

static int mpeg4video_probe(AVProbeData *probe_packet)
{
    uint32_t temp_buffer= -1;
302
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
303 304 305 306
    int i;

    for(i=0; i<probe_packet->buf_size; i++){
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
307 308 309 310 311 312 313 314 315
        if ((temp_buffer & 0xffffff00) != 0x100)
            continue;

        if (temp_buffer == VOP_START_CODE)                         VOP++;
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
        else if (temp_buffer < 0x120)                              VO++;
        else if (temp_buffer < 0x130)                              VOL++;
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
316 317
    }

318
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
319 320 321 322
        return AVPROBE_SCORE_MAX/2;
    return 0;
}

323 324 325 326 327 328 329 330 331 332 333 334 335
static int h263_probe(AVProbeData *p)
{
    int code;
    const uint8_t *d;

    d = p->buf;
    code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
    if (code == 0x20) {
        return 50;
    }
    return 0;
}

336 337 338 339 340 341 342 343 344 345 346 347 348
static int h261_probe(AVProbeData *p)
{
    int code;
    const uint8_t *d;

    d = p->buf;
    code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
    if (code == 0x10) {
        return 50;
    }
    return 0;
}

349 350
static int ac3_probe(AVProbeData *p)
{
351
    int max_frames, first_frames = 0, frames;
352 353
    uint8_t *buf, *buf2, *end;
    AC3HeaderInfo hdr;
354
    GetBitContext gbc;
355

356 357
    max_frames = 0;
    buf = p->buf;
358
    end = buf + p->buf_size;
359 360 361

    for(; buf < end; buf++) {
        buf2 = buf;
362

363
        for(frames = 0; buf2 < end; frames++) {
364 365
            init_get_bits(&gbc, buf2, 54);
            if(ff_ac3_parse_header(&gbc, &hdr) < 0)
366
                break;
367 368 369
            if(buf2 + hdr.frame_size > end ||
               av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
                break;
370 371 372 373 374 375 376
            buf2 += hdr.frame_size;
        }
        max_frames = FFMAX(max_frames, frames);
        if(buf == p->buf)
            first_frames = frames;
    }
    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
377
    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
378 379
    else if(max_frames>=1) return 1;
    else                   return 0;
380 381
}

Michael Niedermayer's avatar
Michael Niedermayer committed
382 383 384
static int flac_probe(AVProbeData *p)
{
    if(memcmp(p->buf, "fLaC", 4)) return 0;
385
    else                          return AVPROBE_SCORE_MAX / 2;
Michael Niedermayer's avatar
Michael Niedermayer committed
386 387
}

388
AVInputFormat shorten_demuxer = {
389
    "shn",
390
    "raw shorten",
391 392
    0,
    NULL,
393
    audio_read_header,
394 395
    raw_read_partial_packet,
    raw_read_close,
396
    .flags= AVFMT_GENERIC_INDEX,
397
    .extensions = "shn",
398
    .value = CODEC_ID_SHORTEN,
399 400
};

401
AVInputFormat flac_demuxer = {
402 403 404
    "flac",
    "raw flac",
    0,
Michael Niedermayer's avatar
Michael Niedermayer committed
405
    flac_probe,
406
    audio_read_header,
407 408
    raw_read_partial_packet,
    raw_read_close,
409
    .flags= AVFMT_GENERIC_INDEX,
410
    .extensions = "flac",
411
    .value = CODEC_ID_FLAC,
412 413
};

414
#ifdef CONFIG_MUXERS
415
AVOutputFormat flac_muxer = {
416 417 418 419 420 421 422 423 424
    "flac",
    "raw flac",
    "audio/x-flac",
    "flac",
    0,
    CODEC_ID_FLAC,
    0,
    flac_write_header,
    raw_write_packet,
425
    .flags= AVFMT_NOTIMESTAMPS,
426 427 428
};
#endif //CONFIG_MUXERS

429
#ifdef CONFIG_AC3_DEMUXER
430
AVInputFormat ac3_demuxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
431 432 433
    "ac3",
    "raw ac3",
    0,
434
    ac3_probe,
435
    audio_read_header,
436
    raw_read_partial_packet,
Fabrice Bellard's avatar
Fabrice Bellard committed
437
    raw_read_close,
438
    .flags= AVFMT_GENERIC_INDEX,
439
    .extensions = "ac3",
440
    .value = CODEC_ID_AC3,
Fabrice Bellard's avatar
Fabrice Bellard committed
441
};
442
#endif
Fabrice Bellard's avatar
Fabrice Bellard committed
443

444
#ifdef CONFIG_MUXERS
445
AVOutputFormat ac3_muxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
446 447
    "ac3",
    "raw ac3",
448
    "audio/x-ac3",
Fabrice Bellard's avatar
Fabrice Bellard committed
449
    "ac3",
Fabrice Bellard's avatar
Fabrice Bellard committed
450
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
451 452
    CODEC_ID_AC3,
    0,
453
    NULL,
Fabrice Bellard's avatar
Fabrice Bellard committed
454
    raw_write_packet,
455
    .flags= AVFMT_NOTIMESTAMPS,
Fabrice Bellard's avatar
Fabrice Bellard committed
456
};
Benjamin Larsson's avatar
Benjamin Larsson committed
457 458 459 460 461 462 463 464 465 466 467 468 469 470

AVOutputFormat dts_muxer = {
    "dts",
    "raw dts",
    "audio/x-dca",
    "dts",
    0,
    CODEC_ID_DTS,
    0,
    NULL,
    raw_write_packet,
    .flags= AVFMT_NOTIMESTAMPS,
};

471
#endif //CONFIG_MUXERS
Fabrice Bellard's avatar
Fabrice Bellard committed
472

473
AVInputFormat dts_demuxer = {
474 475 476 477
    "dts",
    "raw dts",
    0,
    NULL,
478
    audio_read_header,
479 480
    raw_read_partial_packet,
    raw_read_close,
481
    .flags= AVFMT_GENERIC_INDEX,
482
    .extensions = "dts",
483
    .value = CODEC_ID_DTS,
484 485
};

486
AVInputFormat aac_demuxer = {
Måns Rullgård's avatar
Måns Rullgård committed
487 488 489 490
    "aac",
    "ADTS AAC",
    0,
    NULL,
491
    audio_read_header,
Måns Rullgård's avatar
Måns Rullgård committed
492 493
    raw_read_partial_packet,
    raw_read_close,
494
    .flags= AVFMT_GENERIC_INDEX,
Måns Rullgård's avatar
Måns Rullgård committed
495
    .extensions = "aac",
496
    .value = CODEC_ID_AAC,
Måns Rullgård's avatar
Måns Rullgård committed
497 498
};

499 500 501 502 503 504 505 506 507 508 509 510 511
AVInputFormat gsm_demuxer = {
    "gsm",
    "GSM",
    0,
    NULL,
    audio_read_header,
    raw_read_partial_packet,
    raw_read_close,
    .flags= AVFMT_GENERIC_INDEX,
    .extensions = "gsm",
    .value = CODEC_ID_GSM,
};

512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
#ifdef CONFIG_ROQ_MUXER
AVOutputFormat roq_muxer =
{
    "RoQ",
    "Id RoQ format",
    NULL,
    "roq",
    0,
    CODEC_ID_ROQ_DPCM,
    CODEC_ID_ROQ,
    roq_write_header,
    raw_write_packet,
};
#endif //CONFIG_ROQ_MUXER

527
AVInputFormat h261_demuxer = {
528 529 530 531 532 533 534
    "h261",
    "raw h261",
    0,
    h261_probe,
    video_read_header,
    raw_read_partial_packet,
    raw_read_close,
535
    .flags= AVFMT_GENERIC_INDEX,
536 537 538 539
    .extensions = "h261",
    .value = CODEC_ID_H261,
};

540
#ifdef CONFIG_MUXERS
541
AVOutputFormat h261_muxer = {
542 543 544 545 546 547 548
    "h261",
    "raw h261",
    "video/x-h261",
    "h261",
    0,
    0,
    CODEC_ID_H261,
549
    NULL,
550
    raw_write_packet,
551
    .flags= AVFMT_NOTIMESTAMPS,
552
};
553
#endif //CONFIG_MUXERS
554

555
AVInputFormat h263_demuxer = {
556 557 558 559 560
    "h263",
    "raw h263",
    0,
    h263_probe,
    video_read_header,
561
    raw_read_partial_packet,
562
    raw_read_close,
563
    .flags= AVFMT_GENERIC_INDEX,
564 565 566 567
//    .extensions = "h263", //FIXME remove after writing mpeg4_probe
    .value = CODEC_ID_H263,
};

568
#ifdef CONFIG_MUXERS
569
AVOutputFormat h263_muxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
570 571 572 573 574
    "h263",
    "raw h263",
    "video/x-h263",
    "h263",
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
575
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
576
    CODEC_ID_H263,
577
    NULL,
Fabrice Bellard's avatar
Fabrice Bellard committed
578
    raw_write_packet,
579
    .flags= AVFMT_NOTIMESTAMPS,
Fabrice Bellard's avatar
Fabrice Bellard committed
580
};
581
#endif //CONFIG_MUXERS
Fabrice Bellard's avatar
Fabrice Bellard committed
582

583
AVInputFormat m4v_demuxer = {
Michael Niedermayer's avatar
Michael Niedermayer committed
584 585 586
    "m4v",
    "raw MPEG4 video format",
    0,
587
    mpeg4video_probe, /** probing for mpeg4 data */
Michael Niedermayer's avatar
Michael Niedermayer committed
588
    video_read_header,
589
    raw_read_partial_packet,
Michael Niedermayer's avatar
Michael Niedermayer committed
590
    raw_read_close,
591
    .flags= AVFMT_GENERIC_INDEX,
592 593
    .extensions = "m4v", //FIXME remove after writing mpeg4_probe
    .value = CODEC_ID_MPEG4,
Michael Niedermayer's avatar
Michael Niedermayer committed
594 595
};

596
#ifdef CONFIG_MUXERS
597
AVOutputFormat m4v_muxer = {
598 599 600 601 602 603 604
    "m4v",
    "raw MPEG4 video format",
    NULL,
    "m4v",
    0,
    CODEC_ID_NONE,
    CODEC_ID_MPEG4,
605
    NULL,
606
    raw_write_packet,
607
    .flags= AVFMT_NOTIMESTAMPS,
608
};
609
#endif //CONFIG_MUXERS
610

611
AVInputFormat h264_demuxer = {
Michael Niedermayer's avatar
Michael Niedermayer committed
612 613 614 615 616
    "h264",
    "raw H264 video format",
    0,
    NULL /*mpegvideo_probe*/,
    video_read_header,
617
    raw_read_partial_packet,
Michael Niedermayer's avatar
Michael Niedermayer committed
618
    raw_read_close,
619
    .flags= AVFMT_GENERIC_INDEX,
Michael Niedermayer's avatar
.264  
Michael Niedermayer committed
620
    .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
Michael Niedermayer's avatar
Michael Niedermayer committed
621 622 623
    .value = CODEC_ID_H264,
};

624
#ifdef CONFIG_MUXERS
625
AVOutputFormat h264_muxer = {
Michael Niedermayer's avatar
Michael Niedermayer committed
626 627 628 629 630 631 632
    "h264",
    "raw H264 video format",
    NULL,
    "h264",
    0,
    CODEC_ID_NONE,
    CODEC_ID_H264,
633
    NULL,
Michael Niedermayer's avatar
Michael Niedermayer committed
634
    raw_write_packet,
635
    .flags= AVFMT_NOTIMESTAMPS,
Michael Niedermayer's avatar
Michael Niedermayer committed
636
};
637
#endif //CONFIG_MUXERS
Michael Niedermayer's avatar
Michael Niedermayer committed
638

639
AVInputFormat mpegvideo_demuxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
640 641 642 643
    "mpegvideo",
    "MPEG video",
    0,
    mpegvideo_probe,
Fabrice Bellard's avatar
Fabrice Bellard committed
644
    video_read_header,
645
    raw_read_partial_packet,
Fabrice Bellard's avatar
Fabrice Bellard committed
646
    raw_read_close,
647
    .flags= AVFMT_GENERIC_INDEX,
648
    .value = CODEC_ID_MPEG1VIDEO,
Fabrice Bellard's avatar
Fabrice Bellard committed
649 650
};

651
#ifdef CONFIG_MUXERS
652
AVOutputFormat mpeg1video_muxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
653
    "mpeg1video",
Fabrice Bellard's avatar
Fabrice Bellard committed
654 655
    "MPEG video",
    "video/x-mpeg",
656
    "mpg,mpeg,m1v",
Fabrice Bellard's avatar
Fabrice Bellard committed
657
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
658
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
659
    CODEC_ID_MPEG1VIDEO,
660
    NULL,
Fabrice Bellard's avatar
Fabrice Bellard committed
661
    raw_write_packet,
662
    .flags= AVFMT_NOTIMESTAMPS,
Fabrice Bellard's avatar
Fabrice Bellard committed
663
};
664
#endif //CONFIG_MUXERS
Fabrice Bellard's avatar
Fabrice Bellard committed
665

666
#ifdef CONFIG_MUXERS
667
AVOutputFormat mpeg2video_muxer = {
668 669 670 671 672 673 674
    "mpeg2video",
    "MPEG2 video",
    NULL,
    "m2v",
    0,
    0,
    CODEC_ID_MPEG2VIDEO,
675
    NULL,
676
    raw_write_packet,
677
    .flags= AVFMT_NOTIMESTAMPS,
678
};
679
#endif //CONFIG_MUXERS
680

681
AVInputFormat mjpeg_demuxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
682 683 684
    "mjpeg",
    "MJPEG video",
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
685
    NULL,
Fabrice Bellard's avatar
Fabrice Bellard committed
686
    video_read_header,
687
    raw_read_partial_packet,
Fabrice Bellard's avatar
Fabrice Bellard committed
688
    raw_read_close,
689
    .flags= AVFMT_GENERIC_INDEX,
690 691
    .extensions = "mjpg,mjpeg",
    .value = CODEC_ID_MJPEG,
Fabrice Bellard's avatar
Fabrice Bellard committed
692 693
};

694
AVInputFormat ingenient_demuxer = {
695 696 697 698 699 700 701
    "ingenient",
    "Ingenient MJPEG",
    0,
    NULL,
    video_read_header,
    ingenient_read_packet,
    raw_read_close,
702
    .flags= AVFMT_GENERIC_INDEX,
703 704 705 706
    .extensions = "cgi", // FIXME
    .value = CODEC_ID_MJPEG,
};

707
#ifdef CONFIG_MUXERS
708
AVOutputFormat mjpeg_muxer = {
Fabrice Bellard's avatar
Fabrice Bellard committed
709 710 711 712
    "mjpeg",
    "MJPEG video",
    "video/x-mjpeg",
    "mjpg,mjpeg",
Fabrice Bellard's avatar
Fabrice Bellard committed
713 714
    0,
    0,
Fabrice Bellard's avatar
Fabrice Bellard committed
715
    CODEC_ID_MJPEG,
716
    NULL,
Fabrice Bellard's avatar
Fabrice Bellard committed
717
    raw_write_packet,
718
    .flags= AVFMT_NOTIMESTAMPS,
Fabrice Bellard's avatar
Fabrice Bellard committed
719
};
720
#endif //CONFIG_MUXERS
Fabrice Bellard's avatar
Fabrice Bellard committed
721

Kostya Shishkov's avatar
Kostya Shishkov committed
722 723 724 725 726 727 728 729 730 731 732 733
AVInputFormat vc1_demuxer = {
    "vc1",
    "raw vc1",
    0,
    NULL /* vc1_probe */,
    video_read_header,
    raw_read_partial_packet,
    raw_read_close,
    .extensions = "vc1",
    .value = CODEC_ID_VC1,
};

Fabrice Bellard's avatar
Fabrice Bellard committed
734
/* pcm formats */
735

Fabrice Bellard's avatar
Fabrice Bellard committed
736
#define PCMINPUTDEF(name, long_name, ext, codec) \
737
AVInputFormat pcm_ ## name ## _demuxer = {\
738 739 740 741 742 743 744
    #name,\
    long_name,\
    0,\
    NULL,\
    raw_read_header,\
    raw_read_packet,\
    raw_read_close,\
Fabrice Bellard's avatar
Fabrice Bellard committed
745
    pcm_read_seek,\
746
    .flags= AVFMT_GENERIC_INDEX,\
747 748 749 750
    .extensions = ext,\
    .value = codec,\
};

751
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
752
AVOutputFormat pcm_ ## name ## _muxer = {\
Fabrice Bellard's avatar
Fabrice Bellard committed
753 754 755 756 757 758 759
    #name,\
    long_name,\
    NULL,\
    ext,\
    0,\
    codec,\
    0,\
760
    NULL,\
Fabrice Bellard's avatar
Fabrice Bellard committed
761
    raw_write_packet,\
762
    .flags= AVFMT_NOTIMESTAMPS,\
Fabrice Bellard's avatar
Fabrice Bellard committed
763
};
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778


#if !defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
#define PCMDEF(name, long_name, ext, codec) \
        PCMINPUTDEF(name, long_name, ext, codec)
#elif defined(CONFIG_MUXERS) && !defined(CONFIG_DEMUXERS)
#define PCMDEF(name, long_name, ext, codec) \
        PCMOUTPUTDEF(name, long_name, ext, codec)
#elif defined(CONFIG_MUXERS) && defined(CONFIG_DEMUXERS)
#define PCMDEF(name, long_name, ext, codec) \
        PCMINPUTDEF(name, long_name, ext, codec)\
        PCMOUTPUTDEF(name, long_name, ext, codec)
#else
#define PCMDEF(name, long_name, ext, codec)
#endif
Fabrice Bellard's avatar
Fabrice Bellard committed
779 780

#ifdef WORDS_BIGENDIAN
Fabrice Bellard's avatar
Fabrice Bellard committed
781 782
#define BE_DEF(s) s
#define LE_DEF(s) NULL
Fabrice Bellard's avatar
Fabrice Bellard committed
783
#else
Fabrice Bellard's avatar
Fabrice Bellard committed
784 785
#define BE_DEF(s) NULL
#define LE_DEF(s) s
Fabrice Bellard's avatar
Fabrice Bellard committed
786 787 788
#endif


789
PCMDEF(s16le, "pcm signed 16 bit little endian format",
Fabrice Bellard's avatar
Fabrice Bellard committed
790
       LE_DEF("sw"), CODEC_ID_PCM_S16LE)
Fabrice Bellard's avatar
Fabrice Bellard committed
791

792
PCMDEF(s16be, "pcm signed 16 bit big endian format",