Statistics
| Branch: | Revision:

ffmpeg / libavformat / raw.c @ 63613fe6

History | View | Annotate | Download (30.7 KB)

1 115329f1 Diego Biurrun
/*
2 7fbde343 Aurelien Jacobs
 * RAW muxer and demuxer
3 406792e7 Diego Biurrun
 * Copyright (c) 2001 Fabrice Bellard
4 84c63c01 Alex Beregszaszi
 * Copyright (c) 2005 Alex Beregszaszi
5 de6d9b64 Fabrice Bellard
 *
6 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9 19720f15 Fabrice Bellard
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
12 de6d9b64 Fabrice Bellard
 *
13 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
14 de6d9b64 Fabrice Bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 19720f15 Fabrice Bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17 de6d9b64 Fabrice Bellard
 *
18 19720f15 Fabrice Bellard
 * You should have received a copy of the GNU Lesser General Public
19 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
20 5509bffa Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 de6d9b64 Fabrice Bellard
 */
22 245976da Diego Biurrun
23
#include "libavutil/crc.h"
24
#include "libavcodec/ac3_parser.h"
25 9106a698 Stefano Sabatini
#include "libavcodec/get_bits.h"
26 245976da Diego Biurrun
#include "libavcodec/bytestream.h"
27 de6d9b64 Fabrice Bellard
#include "avformat.h"
28 7241a6bb Aurelien Jacobs
#include "raw.h"
29 ac3ef4a4 Alex Converse
#include "id3v2.h"
30 d52b90bd Patrick Dehne
#include "id3v1.h"
31 de6d9b64 Fabrice Bellard
32
/* simple formats */
33 ce1d2a95 Justin Ruggles
34 b250f9c6 Aurelien Jacobs
#if CONFIG_ROQ_MUXER
35 13dec857 Vitor Sessak
static int roq_write_header(struct AVFormatContext *s)
36
{
37
    static const uint8_t header[] = {
38
        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
39
    };
40
41 899681cd Björn Axelsson
    put_buffer(s->pb, header, 8);
42
    put_flush_packet(s->pb);
43 13dec857 Vitor Sessak
44
    return 0;
45
}
46 96445426 Diego Biurrun
#endif
47 13dec857 Vitor Sessak
48 b250f9c6 Aurelien Jacobs
#if CONFIG_NULL_MUXER
49 76d32428 Diego Biurrun
static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
50
{
51
    return 0;
52
}
53 96445426 Diego Biurrun
#endif
54 76d32428 Diego Biurrun
55 b250f9c6 Aurelien Jacobs
#if CONFIG_MUXERS
56 e928649b Michael Niedermayer
static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
57 de6d9b64 Fabrice Bellard
{
58 899681cd Björn Axelsson
    put_buffer(s->pb, pkt->data, pkt->size);
59
    put_flush_packet(s->pb);
60 de6d9b64 Fabrice Bellard
    return 0;
61
}
62 082f7acf Diego Biurrun
#endif
63 de6d9b64 Fabrice Bellard
64 b250f9c6 Aurelien Jacobs
#if CONFIG_DEMUXERS
65 de6d9b64 Fabrice Bellard
/* raw input */
66 0c1a9eda Zdenek Kabelac
static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
67 de6d9b64 Fabrice Bellard
{
68
    AVStream *st;
69 c9a65ca8 Fabrice Bellard
    int id;
70 de6d9b64 Fabrice Bellard
71 c9a65ca8 Fabrice Bellard
    st = av_new_stream(s, 0);
72 de6d9b64 Fabrice Bellard
    if (!st)
73 769e10f0 Panagiotis Issaris
        return AVERROR(ENOMEM);
74 c04c3282 Michael Niedermayer
75 c9a65ca8 Fabrice Bellard
        id = s->iformat->value;
76
        if (id == CODEC_ID_RAWVIDEO) {
77 01f4895c Michael Niedermayer
            st->codec->codec_type = CODEC_TYPE_VIDEO;
78 de6d9b64 Fabrice Bellard
        } else {
79 01f4895c Michael Niedermayer
            st->codec->codec_type = CODEC_TYPE_AUDIO;
80 de6d9b64 Fabrice Bellard
        }
81 01f4895c Michael Niedermayer
        st->codec->codec_id = id;
82 c9a65ca8 Fabrice Bellard
83 01f4895c Michael Niedermayer
        switch(st->codec->codec_type) {
84 de6d9b64 Fabrice Bellard
        case CODEC_TYPE_AUDIO:
85 01f4895c Michael Niedermayer
            st->codec->sample_rate = ap->sample_rate;
86 bf9067cf Michael Niedermayer
            if(ap->channels) st->codec->channels = ap->channels;
87
            else             st->codec->channels = 1;
88 a3d23e15 Baptiste Coudurier
            st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
89
            assert(st->codec->bits_per_coded_sample > 0);
90
            st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
91 01f4895c Michael Niedermayer
            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
92 de6d9b64 Fabrice Bellard
            break;
93
        case CODEC_TYPE_VIDEO:
94 9de0be61 Michael Niedermayer
            if(ap->time_base.num)
95
                av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
96
            else
97
                av_set_pts_info(st, 64, 1, 25);
98 01f4895c Michael Niedermayer
            st->codec->width = ap->width;
99
            st->codec->height = ap->height;
100
            st->codec->pix_fmt = ap->pix_fmt;
101
            if(st->codec->pix_fmt == PIX_FMT_NONE)
102
                st->codec->pix_fmt= PIX_FMT_YUV420P;
103 de6d9b64 Fabrice Bellard
            break;
104
        default:
105 27e084bd Fabrice Bellard
            return -1;
106 de6d9b64 Fabrice Bellard
        }
107
    return 0;
108
}
109
110 2e93e3aa Fabrice Bellard
#define RAW_PACKET_SIZE 1024
111 a3d23e15 Baptiste Coudurier
#define RAW_SAMPLES     1024
112 de6d9b64 Fabrice Bellard
113 5c91a675 Zdenek Kabelac
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
114 de6d9b64 Fabrice Bellard
{
115 f5b41031 Michael Niedermayer
    int ret, size, bps;
116 2a6874fd Fabrice Bellard
    //    AVStream *st = s->streams[0];
117 115329f1 Diego Biurrun
118 a3d23e15 Baptiste Coudurier
    size= RAW_SAMPLES*s->streams[0]->codec->block_align;
119 de6d9b64 Fabrice Bellard
120 899681cd Björn Axelsson
    ret= av_get_packet(s->pb, pkt, size);
121 de6d9b64 Fabrice Bellard
122
    pkt->stream_index = 0;
123 2e93e3aa Fabrice Bellard
    if (ret <= 0) {
124 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO);
125 2e93e3aa Fabrice Bellard
    }
126
    /* note: we need to modify the packet size here to handle the last
127
       packet */
128
    pkt->size = ret;
129 f5b41031 Michael Niedermayer
130
    bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
131
    assert(bps); // if false there IS a bug elsewhere (NOT in this function)
132
    pkt->dts=
133
    pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
134
135 de6d9b64 Fabrice Bellard
    return ret;
136
}
137
138 81f052cb Justin Ruggles
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
139 e15dec10 Leon van Stuivenberg
{
140
    int ret, size;
141
142
    size = RAW_PACKET_SIZE;
143
144
    if (av_new_packet(pkt, size) < 0)
145 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO);
146 115329f1 Diego Biurrun
147 899681cd Björn Axelsson
    pkt->pos= url_ftell(s->pb);
148 e15dec10 Leon van Stuivenberg
    pkt->stream_index = 0;
149 899681cd Björn Axelsson
    ret = get_partial_buffer(s->pb, pkt->data, size);
150 e15dec10 Leon van Stuivenberg
    if (ret <= 0) {
151
        av_free_packet(pkt);
152 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO);
153 e15dec10 Leon van Stuivenberg
    }
154
    pkt->size = ret;
155
    return ret;
156
}
157 4c00864f Diego Biurrun
#endif
158 e15dec10 Leon van Stuivenberg
159 b250f9c6 Aurelien Jacobs
#if CONFIG_RAWVIDEO_DEMUXER
160 76d32428 Diego Biurrun
static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
161
{
162
    int packet_size, ret, width, height;
163
    AVStream *st = s->streams[0];
164
165
    width = st->codec->width;
166
    height = st->codec->height;
167
168
    packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
169
    if (packet_size < 0)
170
        return -1;
171
172
    ret= av_get_packet(s->pb, pkt, packet_size);
173
    pkt->pts=
174
    pkt->dts= pkt->pos / packet_size;
175
176
    pkt->stream_index = 0;
177
    if (ret != packet_size) {
178
        return AVERROR(EIO);
179
    } else {
180
        return 0;
181
    }
182
}
183 4c00864f Diego Biurrun
#endif
184 76d32428 Diego Biurrun
185 b250f9c6 Aurelien Jacobs
#if CONFIG_INGENIENT_DEMUXER
186 84c63c01 Alex Beregszaszi
// http://www.artificis.hu/files/texts/ingenient.txt
187
static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
188
{
189
    int ret, size, w, h, unk1, unk2;
190 115329f1 Diego Biurrun
191 899681cd Björn Axelsson
    if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
192 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO); // FIXME
193 84c63c01 Alex Beregszaszi
194 899681cd Björn Axelsson
    size = get_le32(s->pb);
195 115329f1 Diego Biurrun
196 899681cd Björn Axelsson
    w = get_le16(s->pb);
197
    h = get_le16(s->pb);
198 115329f1 Diego Biurrun
199 899681cd Björn Axelsson
    url_fskip(s->pb, 8); // zero + size (padded?)
200
    url_fskip(s->pb, 2);
201
    unk1 = get_le16(s->pb);
202
    unk2 = get_le16(s->pb);
203 fb9f1117 Diego Biurrun
    url_fskip(s->pb, 22); // ASCII timestamp
204 115329f1 Diego Biurrun
205 ff9843ca Benoit Fouet
    av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
206 bb270c08 Diego Biurrun
        size, w, h, unk1, unk2);
207 84c63c01 Alex Beregszaszi
208
    if (av_new_packet(pkt, size) < 0)
209 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO);
210 84c63c01 Alex Beregszaszi
211 899681cd Björn Axelsson
    pkt->pos = url_ftell(s->pb);
212 84c63c01 Alex Beregszaszi
    pkt->stream_index = 0;
213 899681cd Björn Axelsson
    ret = get_buffer(s->pb, pkt->data, size);
214 84c63c01 Alex Beregszaszi
    if (ret <= 0) {
215
        av_free_packet(pkt);
216 6f3e0b21 Panagiotis Issaris
        return AVERROR(EIO);
217 84c63c01 Alex Beregszaszi
    }
218
    pkt->size = ret;
219
    return ret;
220
}
221 4c00864f Diego Biurrun
#endif
222 84c63c01 Alex Beregszaszi
223 b250f9c6 Aurelien Jacobs
#if CONFIG_DEMUXERS
224 115329f1 Diego Biurrun
int pcm_read_seek(AVFormatContext *s,
225 7b3c1382 Michael Niedermayer
                  int stream_index, int64_t timestamp, int flags)
226 4986a429 Fabrice Bellard
{
227
    AVStream *st;
228 d701934b Baptiste Coudurier
    int block_align, byte_rate, ret;
229 4986a429 Fabrice Bellard
    int64_t pos;
230
231
    st = s->streams[0];
232 708e3e7d Baptiste Coudurier
233
    block_align = st->codec->block_align ? st->codec->block_align :
234
        (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
235
    byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
236
        block_align * st->codec->sample_rate;
237 115329f1 Diego Biurrun
238 4986a429 Fabrice Bellard
    if (block_align <= 0 || byte_rate <= 0)
239
        return -1;
240 bd36f175 Reimar Döffinger
    if (timestamp < 0) timestamp = 0;
241 4986a429 Fabrice Bellard
242
    /* compute the position by aligning it to block_align */
243 115329f1 Diego Biurrun
    pos = av_rescale_rnd(timestamp * byte_rate,
244
                         st->time_base.num,
245 7b3c1382 Michael Niedermayer
                         st->time_base.den * (int64_t)block_align,
246
                         (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
247
    pos *= block_align;
248 4986a429 Fabrice Bellard
249
    /* recompute exact position */
250 77405fc8 Michael Niedermayer
    st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
251 d701934b Baptiste Coudurier
    if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
252
        return ret;
253 4986a429 Fabrice Bellard
    return 0;
254
}
255
256 a0af2fa4 Baptiste Coudurier
static int audio_read_header(AVFormatContext *s,
257
                             AVFormatParameters *ap)
258 fda885c7 Måns Rullgård
{
259 a0af2fa4 Baptiste Coudurier
    AVStream *st = av_new_stream(s, 0);
260 fda885c7 Måns Rullgård
    if (!st)
261 769e10f0 Panagiotis Issaris
        return AVERROR(ENOMEM);
262 fda885c7 Måns Rullgård
    st->codec->codec_type = CODEC_TYPE_AUDIO;
263 a0af2fa4 Baptiste Coudurier
    st->codec->codec_id = s->iformat->value;
264 57004ff1 Aurelien Jacobs
    st->need_parsing = AVSTREAM_PARSE_FULL;
265 fda885c7 Måns Rullgård
    /* the parameters will be extracted from the compressed bitstream */
266 6cde949a David DeHaven
267 fda885c7 Måns Rullgård
    return 0;
268
}
269
270 fb9f1117 Diego Biurrun
/* MPEG-1/H.263 input */
271 de6d9b64 Fabrice Bellard
static int video_read_header(AVFormatContext *s,
272
                             AVFormatParameters *ap)
273
{
274
    AVStream *st;
275
276 c9a65ca8 Fabrice Bellard
    st = av_new_stream(s, 0);
277 de6d9b64 Fabrice Bellard
    if (!st)
278 769e10f0 Panagiotis Issaris
        return AVERROR(ENOMEM);
279 de6d9b64 Fabrice Bellard
280 01f4895c Michael Niedermayer
    st->codec->codec_type = CODEC_TYPE_VIDEO;
281
    st->codec->codec_id = s->iformat->value;
282 57004ff1 Aurelien Jacobs
    st->need_parsing = AVSTREAM_PARSE_FULL;
283 4986a429 Fabrice Bellard
284 fb9f1117 Diego Biurrun
    /* for MJPEG, specify frame rate */
285
    /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
286 c04c3282 Michael Niedermayer
    if (ap->time_base.num) {
287 4022fe01 Michael Niedermayer
        st->codec->time_base= ap->time_base;
288 115329f1 Diego Biurrun
    } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
289 01f4895c Michael Niedermayer
                st->codec->codec_id == CODEC_ID_MPEG4 ||
290 17ac9f1c Luca Barbato
                st->codec->codec_id == CODEC_ID_DIRAC ||
291 01f4895c Michael Niedermayer
                st->codec->codec_id == CODEC_ID_H264) {
292 4022fe01 Michael Niedermayer
        st->codec->time_base= (AVRational){1,25};
293 27e084bd Fabrice Bellard
    }
294 4022fe01 Michael Niedermayer
    av_set_pts_info(st, 64, 1, 1200000);
295 80ce3254 Michael Niedermayer
296 de6d9b64 Fabrice Bellard
    return 0;
297
}
298 4c00864f Diego Biurrun
#endif
299 de6d9b64 Fabrice Bellard
300 b250f9c6 Aurelien Jacobs
#if CONFIG_MPEGVIDEO_DEMUXER
301 bb270c08 Diego Biurrun
#define SEQ_START_CODE          0x000001b3
302
#define GOP_START_CODE          0x000001b8
303
#define PICTURE_START_CODE      0x00000100
304 93d3e278 Michael Niedermayer
#define SLICE_START_CODE        0x00000101
305
#define PACK_START_CODE         0x000001ba
306 e01dc227 Måns Rullgård
#define VIDEO_ID                0x000001e0
307
#define AUDIO_ID                0x000001c0
308 c9a65ca8 Fabrice Bellard
309
static int mpegvideo_probe(AVProbeData *p)
310
{
311 93d3e278 Michael Niedermayer
    uint32_t code= -1;
312 e01dc227 Måns Rullgård
    int pic=0, seq=0, slice=0, pspack=0, pes=0;
313 93d3e278 Michael Niedermayer
    int i;
314
315
    for(i=0; i<p->buf_size; i++){
316
        code = (code<<8) + p->buf[i];
317
        if ((code & 0xffffff00) == 0x100) {
318
            switch(code){
319
            case     SEQ_START_CODE:   seq++; break;
320
            case PICTURE_START_CODE:   pic++; break;
321
            case   SLICE_START_CODE: slice++; break;
322
            case    PACK_START_CODE: pspack++; break;
323
            }
324 e9f6c8ea Michael Niedermayer
            if     ((code & 0x1f0) == VIDEO_ID)   pes++;
325
            else if((code & 0x1e0) == AUDIO_ID)   pes++;
326 93d3e278 Michael Niedermayer
        }
327 c9a65ca8 Fabrice Bellard
    }
328 e01dc227 Måns Rullgård
    if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
329 93d3e278 Michael Niedermayer
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
330 c9a65ca8 Fabrice Bellard
    return 0;
331
}
332 23251d75 Aurelien Jacobs
#endif
333 9f2fc126 Stefan Gehrer
334 23251d75 Aurelien Jacobs
#if CONFIG_CAVSVIDEO_DEMUXER
335 9f2fc126 Stefan Gehrer
#define CAVS_SEQ_START_CODE       0x000001b0
336
#define CAVS_PIC_I_START_CODE     0x000001b3
337
#define CAVS_UNDEF_START_CODE     0x000001b4
338
#define CAVS_PIC_PB_START_CODE    0x000001b6
339
#define CAVS_VIDEO_EDIT_CODE      0x000001b7
340
#define CAVS_PROFILE_JIZHUN       0x20
341
342
static int cavsvideo_probe(AVProbeData *p)
343
{
344
    uint32_t code= -1;
345
    int pic=0, seq=0, slice_pos = 0;
346
    int i;
347
348
    for(i=0; i<p->buf_size; i++){
349
        code = (code<<8) + p->buf[i];
350
        if ((code & 0xffffff00) == 0x100) {
351
            if(code < CAVS_SEQ_START_CODE) {
352
                /* slices have to be consecutive */
353
                if(code < slice_pos)
354
                    return 0;
355
                slice_pos = code;
356
            } else {
357
                slice_pos = 0;
358
            }
359
            if (code == CAVS_SEQ_START_CODE) {
360
                seq++;
361
                /* check for the only currently supported profile */
362
                if(p->buf[i+1] != CAVS_PROFILE_JIZHUN)
363
                    return 0;
364
            } else if ((code == CAVS_PIC_I_START_CODE) ||
365
                       (code == CAVS_PIC_PB_START_CODE)) {
366
                pic++;
367
            } else if ((code == CAVS_UNDEF_START_CODE) ||
368
                       (code >  CAVS_VIDEO_EDIT_CODE)) {
369
                return 0;
370
            }
371
        }
372
    }
373
    if(seq && seq*9<=pic*10)
374
        return AVPROBE_SCORE_MAX/2;
375
    return 0;
376
}
377 4c00864f Diego Biurrun
#endif
378 c9a65ca8 Fabrice Bellard
379 b250f9c6 Aurelien Jacobs
#if CONFIG_M4V_DEMUXER
380 8f57cc5a Thijs Vermeir
#define VISUAL_OBJECT_START_CODE       0x000001b5
381
#define VOP_START_CODE                 0x000001b6
382
383
static int mpeg4video_probe(AVProbeData *probe_packet)
384
{
385
    uint32_t temp_buffer= -1;
386 5fd5d0ef Michael Niedermayer
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
387 8f57cc5a Thijs Vermeir
    int i;
388
389
    for(i=0; i<probe_packet->buf_size; i++){
390
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
391 c21f308e Roman Shaposhnik
        if ((temp_buffer & 0xffffff00) != 0x100)
392
            continue;
393
394
        if (temp_buffer == VOP_START_CODE)                         VOP++;
395
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
396
        else if (temp_buffer < 0x120)                              VO++;
397
        else if (temp_buffer < 0x130)                              VOL++;
398
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
399
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
400 8f57cc5a Thijs Vermeir
    }
401
402 5fd5d0ef Michael Niedermayer
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
403 8f57cc5a Thijs Vermeir
        return AVPROBE_SCORE_MAX/2;
404
    return 0;
405
}
406 4c00864f Diego Biurrun
#endif
407 8f57cc5a Thijs Vermeir
408 b250f9c6 Aurelien Jacobs
#if CONFIG_H264_DEMUXER
409 010acd8e Michael Niedermayer
static int h264_probe(AVProbeData *p)
410
{
411
    uint32_t code= -1;
412 01037451 Michael Niedermayer
    int sps=0, pps=0, idr=0, res=0, sli=0;
413 010acd8e Michael Niedermayer
    int i;
414
415
    for(i=0; i<p->buf_size; i++){
416
        code = (code<<8) + p->buf[i];
417
        if ((code & 0xffffff00) == 0x100) {
418
            int ref_idc= (code>>5)&3;
419
            int type   = code & 0x1F;
420
            static const int8_t ref_zero[32]={
421
                2, 0, 0, 0, 0,-1, 1,-1,
422
               -1, 1, 1, 1, 1,-1, 2, 2,
423
                2, 2, 2, 0, 2, 2, 2, 2,
424
                2, 2, 2, 2, 2, 2, 2, 2
425
            };
426
427
            if(code & 0x80) //forbidden bit
428
                return 0;
429
430
            if(ref_zero[type] == 1 && ref_idc)
431
                return 0;
432
            if(ref_zero[type] ==-1 && !ref_idc)
433
                return 0;
434
            if(ref_zero[type] == 2)
435
                res++;
436
437
            switch(type){
438 01037451 Michael Niedermayer
            case     1:   sli++; break;
439 010acd8e Michael Niedermayer
            case     5:   idr++; break;
440
            case     7:
441
                if(p->buf[i+2]&0x0F)
442
                    return 0;
443
                sps++;
444
                break;
445
            case     8:   pps++; break;
446
            }
447
        }
448
    }
449 01037451 Michael Niedermayer
    if(sps && pps && (idr||sli>3) && res<(sps+pps+idr))
450 010acd8e Michael Niedermayer
        return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg
451
    return 0;
452
}
453 4c00864f Diego Biurrun
#endif
454 010acd8e Michael Niedermayer
455 b250f9c6 Aurelien Jacobs
#if CONFIG_H263_DEMUXER
456 d07f9043 Michael Niedermayer
static int h263_probe(AVProbeData *p)
457
{
458
    int code;
459
    const uint8_t *d;
460
461
    d = p->buf;
462
    code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
463
    if (code == 0x20) {
464
        return 50;
465
    }
466
    return 0;
467
}
468 4c00864f Diego Biurrun
#endif
469 d07f9043 Michael Niedermayer
470 b250f9c6 Aurelien Jacobs
#if CONFIG_H261_DEMUXER
471 c6148de2 Michael Niedermayer
static int h261_probe(AVProbeData *p)
472
{
473
    int code;
474
    const uint8_t *d;
475
476
    d = p->buf;
477
    code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4);
478
    if (code == 0x10) {
479
        return 50;
480
    }
481
    return 0;
482
}
483 4c00864f Diego Biurrun
#endif
484 c6148de2 Michael Niedermayer
485 b250f9c6 Aurelien Jacobs
#if CONFIG_DTS_DEMUXER
486 fde8052e Benjamin Larsson
#define DCA_MARKER_14B_BE 0x1FFFE800
487
#define DCA_MARKER_14B_LE 0xFF1F00E8
488
#define DCA_MARKER_RAW_BE 0x7FFE8001
489
#define DCA_MARKER_RAW_LE 0xFE7F0180
490
static int dts_probe(AVProbeData *p)
491
{
492
    const uint8_t *buf, *bufp;
493
    uint32_t state = -1;
494
495
    buf = p->buf;
496
497
    for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
498
        bufp = buf;
499
        state = (state << 16) | bytestream_get_be16(&bufp);
500
501 fb9f1117 Diego Biurrun
        /* regular bitstream */
502 fde8052e Benjamin Larsson
        if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE)
503
            return AVPROBE_SCORE_MAX/2+1;
504
505 fb9f1117 Diego Biurrun
        /* 14 bits big-endian bitstream */
506 fde8052e Benjamin Larsson
        if (state == DCA_MARKER_14B_BE)
507
            if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
508
                return AVPROBE_SCORE_MAX/2+1;
509
510 fb9f1117 Diego Biurrun
        /* 14 bits little-endian bitstream */
511 fde8052e Benjamin Larsson
        if (state == DCA_MARKER_14B_LE)
512
            if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
513
                return AVPROBE_SCORE_MAX/2+1;
514
    }
515
516
    return 0;
517
}
518 4c00864f Diego Biurrun
#endif
519 fde8052e Benjamin Larsson
520 b250f9c6 Aurelien Jacobs
#if CONFIG_DIRAC_DEMUXER
521 17ac9f1c Luca Barbato
static int dirac_probe(AVProbeData *p)
522
{
523
    if (AV_RL32(p->buf) == MKTAG('B', 'B', 'C', 'D'))
524
        return AVPROBE_SCORE_MAX;
525
    else
526
        return 0;
527
}
528 4c00864f Diego Biurrun
#endif
529 17ac9f1c Luca Barbato
530 b250f9c6 Aurelien Jacobs
#if CONFIG_DNXHD_DEMUXER
531 bd09e8a7 Baptiste Coudurier
static int dnxhd_probe(AVProbeData *p)
532
{
533
    static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
534
    if (!memcmp(p->buf, header, 5))
535
        return AVPROBE_SCORE_MAX;
536
    else
537
        return 0;
538
}
539
#endif
540
541 b250f9c6 Aurelien Jacobs
#if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
542 75198e7a Aurelien Jacobs
static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
543 7156aeb9 Justin Ruggles
{
544 8c222bb4 Måns Rullgård
    int max_frames, first_frames = 0, frames;
545 f8b9830b Justin Ruggles
    uint8_t *buf, *buf2, *end;
546
    AC3HeaderInfo hdr;
547 55736cfb Bartlomiej Wolowiec
    GetBitContext gbc;
548 75198e7a Aurelien Jacobs
    enum CodecID codec_id = CODEC_ID_AC3;
549 7156aeb9 Justin Ruggles
550 f8b9830b Justin Ruggles
    max_frames = 0;
551
    buf = p->buf;
552 ecc8fc11 Justin Ruggles
    end = buf + p->buf_size;
553 f8b9830b Justin Ruggles
554
    for(; buf < end; buf++) {
555
        buf2 = buf;
556 7156aeb9 Justin Ruggles
557 f8b9830b Justin Ruggles
        for(frames = 0; buf2 < end; frames++) {
558 55736cfb Bartlomiej Wolowiec
            init_get_bits(&gbc, buf2, 54);
559
            if(ff_ac3_parse_header(&gbc, &hdr) < 0)
560 f8b9830b Justin Ruggles
                break;
561 c675ef70 Andreas Öman
            if(buf2 + hdr.frame_size > end ||
562
               av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
563
                break;
564 2988c93d Justin Ruggles
            if (hdr.bitstream_id > 10)
565 75198e7a Aurelien Jacobs
                codec_id = CODEC_ID_EAC3;
566 f8b9830b Justin Ruggles
            buf2 += hdr.frame_size;
567
        }
568
        max_frames = FFMAX(max_frames, frames);
569
        if(buf == p->buf)
570
            first_frames = frames;
571
    }
572 75198e7a Aurelien Jacobs
    if(codec_id != expected_codec_id) return 0;
573 f8b9830b Justin Ruggles
    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
574 2477ce23 Justin Ruggles
    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
575 f8b9830b Justin Ruggles
    else if(max_frames>=1) return 1;
576
    else                   return 0;
577 7156aeb9 Justin Ruggles
}
578 4c00864f Diego Biurrun
#endif
579 7156aeb9 Justin Ruggles
580 b250f9c6 Aurelien Jacobs
#if CONFIG_AC3_DEMUXER
581 2988c93d Justin Ruggles
static int ac3_probe(AVProbeData *p)
582
{
583 75198e7a Aurelien Jacobs
    return ac3_eac3_probe(p, CODEC_ID_AC3);
584 2988c93d Justin Ruggles
}
585
#endif
586
587 b250f9c6 Aurelien Jacobs
#if CONFIG_EAC3_DEMUXER
588 2988c93d Justin Ruggles
static int eac3_probe(AVProbeData *p)
589
{
590 75198e7a Aurelien Jacobs
    return ac3_eac3_probe(p, CODEC_ID_EAC3);
591 2988c93d Justin Ruggles
}
592
#endif
593
594 b250f9c6 Aurelien Jacobs
#if CONFIG_AAC_DEMUXER
595 2ba0cdd5 Michael Niedermayer
static int adts_aac_probe(AVProbeData *p)
596
{
597
    int max_frames = 0, first_frames = 0;
598
    int fsize, frames;
599 ac3ef4a4 Alex Converse
    uint8_t *buf0 = p->buf;
600 2ba0cdd5 Michael Niedermayer
    uint8_t *buf2;
601 ac3ef4a4 Alex Converse
    uint8_t *buf;
602
    uint8_t *end = buf0 + p->buf_size - 7;
603
604
    if (ff_id3v2_match(buf0)) {
605
        buf0 += ff_id3v2_tag_len(buf0);
606
    }
607
    buf = buf0;
608 2ba0cdd5 Michael Niedermayer
609
    for(; buf < end; buf= buf2+1) {
610
        buf2 = buf;
611
612
        for(frames = 0; buf2 < end; frames++) {
613
            uint32_t header = AV_RB16(buf2);
614
            if((header&0xFFF6) != 0xFFF0)
615
                break;
616
            fsize = (AV_RB32(buf2+3)>>13) & 0x8FFF;
617
            if(fsize < 7)
618
                break;
619
            buf2 += fsize;
620
        }
621
        max_frames = FFMAX(max_frames, frames);
622 ac3ef4a4 Alex Converse
        if(buf == buf0)
623 2ba0cdd5 Michael Niedermayer
            first_frames= frames;
624
    }
625
    if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
626
    else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
627
    else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
628
    else if(max_frames>=1) return 1;
629
    else                   return 0;
630
}
631 d52b90bd Patrick Dehne
632
static int adts_aac_read_header(AVFormatContext *s,
633
                                AVFormatParameters *ap)
634
{
635
    AVStream *st;
636
637
    st = av_new_stream(s, 0);
638
    if (!st)
639
        return AVERROR(ENOMEM);
640
641
    st->codec->codec_type = CODEC_TYPE_AUDIO;
642
    st->codec->codec_id = s->iformat->value;
643
    st->need_parsing = AVSTREAM_PARSE_FULL;
644
645
    ff_id3v1_read(s);
646
    ff_id3v2_read(s);
647
648
    return 0;
649
}
650
651 2ba0cdd5 Michael Niedermayer
#endif
652 900eb63d Diego Biurrun
653
/* Note: Do not forget to add new entries to the Makefile as well. */
654
655 b250f9c6 Aurelien Jacobs
#if CONFIG_AAC_DEMUXER
656 76d32428 Diego Biurrun
AVInputFormat aac_demuxer = {
657
    "aac",
658 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw ADTS AAC"),
659 16e861e3 Ramiro Polla
    0,
660 2ba0cdd5 Michael Niedermayer
    adts_aac_probe,
661 d52b90bd Patrick Dehne
    adts_aac_read_header,
662 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
663 16e861e3 Ramiro Polla
    .flags= AVFMT_GENERIC_INDEX,
664 76d32428 Diego Biurrun
    .extensions = "aac",
665
    .value = CODEC_ID_AAC,
666 ce1d2a95 Justin Ruggles
};
667 7402ee23 Diego Biurrun
#endif
668 ce1d2a95 Justin Ruggles
669 b250f9c6 Aurelien Jacobs
#if CONFIG_AC3_DEMUXER
670 d2a067d1 Måns Rullgård
AVInputFormat ac3_demuxer = {
671 c9a65ca8 Fabrice Bellard
    "ac3",
672 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw AC-3"),
673 c9a65ca8 Fabrice Bellard
    0,
674 7156aeb9 Justin Ruggles
    ac3_probe,
675 a0af2fa4 Baptiste Coudurier
    audio_read_header,
676 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
677 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
678 bb76a117 Måns Rullgård
    .extensions = "ac3",
679 a0af2fa4 Baptiste Coudurier
    .value = CODEC_ID_AC3,
680 de6d9b64 Fabrice Bellard
};
681 cefd4907 Diego Biurrun
#endif
682 de6d9b64 Fabrice Bellard
683 b250f9c6 Aurelien Jacobs
#if CONFIG_AC3_MUXER
684 d2a067d1 Måns Rullgård
AVOutputFormat ac3_muxer = {
685 de6d9b64 Fabrice Bellard
    "ac3",
686 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw AC-3"),
687 115329f1 Diego Biurrun
    "audio/x-ac3",
688 de6d9b64 Fabrice Bellard
    "ac3",
689 c9a65ca8 Fabrice Bellard
    0,
690 de6d9b64 Fabrice Bellard
    CODEC_ID_AC3,
691 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
692 7a97dd84 Baptiste Coudurier
    NULL,
693 de6d9b64 Fabrice Bellard
    raw_write_packet,
694 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
695 de6d9b64 Fabrice Bellard
};
696 082f7acf Diego Biurrun
#endif
697 de6d9b64 Fabrice Bellard
698 b250f9c6 Aurelien Jacobs
#if CONFIG_DIRAC_DEMUXER
699 17ac9f1c Luca Barbato
AVInputFormat dirac_demuxer = {
700
    "dirac",
701 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw Dirac"),
702 17ac9f1c Luca Barbato
    0,
703
    dirac_probe,
704
    video_read_header,
705 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
706 17ac9f1c Luca Barbato
    .flags= AVFMT_GENERIC_INDEX,
707
    .value = CODEC_ID_DIRAC,
708
};
709 7402ee23 Diego Biurrun
#endif
710 17ac9f1c Luca Barbato
711 b250f9c6 Aurelien Jacobs
#if CONFIG_DIRAC_MUXER
712 17ac9f1c Luca Barbato
AVOutputFormat dirac_muxer = {
713
    "dirac",
714 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw Dirac"),
715 17ac9f1c Luca Barbato
    NULL,
716
    "drc",
717
    0,
718 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
719 17ac9f1c Luca Barbato
    CODEC_ID_DIRAC,
720
    NULL,
721
    raw_write_packet,
722
    .flags= AVFMT_NOTIMESTAMPS,
723
};
724
#endif
725
726 b250f9c6 Aurelien Jacobs
#if CONFIG_DNXHD_DEMUXER
727 bd09e8a7 Baptiste Coudurier
AVInputFormat dnxhd_demuxer = {
728
    "dnxhd",
729
    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
730
    0,
731
    dnxhd_probe,
732
    video_read_header,
733 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
734 bd09e8a7 Baptiste Coudurier
    .flags= AVFMT_GENERIC_INDEX,
735
    .value = CODEC_ID_DNXHD,
736
};
737
#endif
738
739 b250f9c6 Aurelien Jacobs
#if CONFIG_DNXHD_MUXER
740 bd09e8a7 Baptiste Coudurier
AVOutputFormat dnxhd_muxer = {
741
    "dnxhd",
742
    NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
743
    NULL,
744
    "dnxhd",
745
    0,
746
    CODEC_ID_NONE,
747
    CODEC_ID_DNXHD,
748
    NULL,
749
    raw_write_packet,
750
    .flags= AVFMT_NOTIMESTAMPS,
751
};
752
#endif
753
754 b250f9c6 Aurelien Jacobs
#if CONFIG_DTS_DEMUXER
755 d2a067d1 Måns Rullgård
AVInputFormat dts_demuxer = {
756 23c99253 Michael Niedermayer
    "dts",
757 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw DTS"),
758 23c99253 Michael Niedermayer
    0,
759 fde8052e Benjamin Larsson
    dts_probe,
760 a0af2fa4 Baptiste Coudurier
    audio_read_header,
761 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
762 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
763 23c99253 Michael Niedermayer
    .extensions = "dts",
764 a0af2fa4 Baptiste Coudurier
    .value = CODEC_ID_DTS,
765 23c99253 Michael Niedermayer
};
766 7402ee23 Diego Biurrun
#endif
767 23c99253 Michael Niedermayer
768 b250f9c6 Aurelien Jacobs
#if CONFIG_DTS_MUXER
769 76d32428 Diego Biurrun
AVOutputFormat dts_muxer = {
770
    "dts",
771
    NULL_IF_CONFIG_SMALL("raw DTS"),
772
    "audio/x-dca",
773
    "dts",
774 fda885c7 Måns Rullgård
    0,
775 76d32428 Diego Biurrun
    CODEC_ID_DTS,
776
    CODEC_ID_NONE,
777 fda885c7 Måns Rullgård
    NULL,
778 76d32428 Diego Biurrun
    raw_write_packet,
779
    .flags= AVFMT_NOTIMESTAMPS,
780
};
781
#endif
782
783 b250f9c6 Aurelien Jacobs
#if CONFIG_EAC3_DEMUXER
784 2988c93d Justin Ruggles
AVInputFormat eac3_demuxer = {
785
    "eac3",
786
    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
787
    0,
788
    eac3_probe,
789
    audio_read_header,
790 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
791 2988c93d Justin Ruggles
    .flags= AVFMT_GENERIC_INDEX,
792
    .extensions = "eac3",
793
    .value = CODEC_ID_EAC3,
794
};
795
#endif
796
797 b250f9c6 Aurelien Jacobs
#if CONFIG_EAC3_MUXER
798 2988c93d Justin Ruggles
AVOutputFormat eac3_muxer = {
799
    "eac3",
800
    NULL_IF_CONFIG_SMALL("raw E-AC-3"),
801
    "audio/x-eac3",
802
    "eac3",
803
    0,
804
    CODEC_ID_EAC3,
805
    CODEC_ID_NONE,
806
    NULL,
807
    raw_write_packet,
808
    .flags= AVFMT_NOTIMESTAMPS,
809
};
810
#endif
811
812 b250f9c6 Aurelien Jacobs
#if CONFIG_GSM_DEMUXER
813 60711e95 Michael Niedermayer
AVInputFormat gsm_demuxer = {
814
    "gsm",
815 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw GSM"),
816 60711e95 Michael Niedermayer
    0,
817
    NULL,
818
    audio_read_header,
819 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
820 60711e95 Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
821
    .extensions = "gsm",
822
    .value = CODEC_ID_GSM,
823
};
824 7402ee23 Diego Biurrun
#endif
825 60711e95 Michael Niedermayer
826 b250f9c6 Aurelien Jacobs
#if CONFIG_H261_DEMUXER
827 d2a067d1 Måns Rullgård
AVInputFormat h261_demuxer = {
828 c6148de2 Michael Niedermayer
    "h261",
829 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw H.261"),
830 c6148de2 Michael Niedermayer
    0,
831
    h261_probe,
832
    video_read_header,
833 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
834 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
835 c6148de2 Michael Niedermayer
    .extensions = "h261",
836
    .value = CODEC_ID_H261,
837
};
838 7402ee23 Diego Biurrun
#endif
839 c6148de2 Michael Niedermayer
840 b250f9c6 Aurelien Jacobs
#if CONFIG_H261_MUXER
841 d2a067d1 Måns Rullgård
AVOutputFormat h261_muxer = {
842 1c3990db Michael Niedermayer
    "h261",
843 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw H.261"),
844 1c3990db Michael Niedermayer
    "video/x-h261",
845
    "h261",
846
    0,
847 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
848 1c3990db Michael Niedermayer
    CODEC_ID_H261,
849 7a97dd84 Baptiste Coudurier
    NULL,
850 1c3990db Michael Niedermayer
    raw_write_packet,
851 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
852 1c3990db Michael Niedermayer
};
853 082f7acf Diego Biurrun
#endif
854 1c3990db Michael Niedermayer
855 b250f9c6 Aurelien Jacobs
#if CONFIG_H263_DEMUXER
856 d2a067d1 Måns Rullgård
AVInputFormat h263_demuxer = {
857 d07f9043 Michael Niedermayer
    "h263",
858 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw H.263"),
859 d07f9043 Michael Niedermayer
    0,
860
    h263_probe,
861
    video_read_header,
862 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
863 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
864 d07f9043 Michael Niedermayer
//    .extensions = "h263", //FIXME remove after writing mpeg4_probe
865
    .value = CODEC_ID_H263,
866
};
867 7402ee23 Diego Biurrun
#endif
868 d07f9043 Michael Niedermayer
869 b250f9c6 Aurelien Jacobs
#if CONFIG_H263_MUXER
870 d2a067d1 Måns Rullgård
AVOutputFormat h263_muxer = {
871 de6d9b64 Fabrice Bellard
    "h263",
872 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw H.263"),
873 de6d9b64 Fabrice Bellard
    "video/x-h263",
874
    "h263",
875
    0,
876 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
877 de6d9b64 Fabrice Bellard
    CODEC_ID_H263,
878 7a97dd84 Baptiste Coudurier
    NULL,
879 de6d9b64 Fabrice Bellard
    raw_write_packet,
880 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
881 c9a65ca8 Fabrice Bellard
};
882 082f7acf Diego Biurrun
#endif
883 c9a65ca8 Fabrice Bellard
884 b250f9c6 Aurelien Jacobs
#if CONFIG_H264_DEMUXER
885 76d32428 Diego Biurrun
AVInputFormat h264_demuxer = {
886
    "h264",
887
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
888
    0,
889 010acd8e Michael Niedermayer
    h264_probe,
890 76d32428 Diego Biurrun
    video_read_header,
891 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
892 76d32428 Diego Biurrun
    .flags= AVFMT_GENERIC_INDEX,
893
    .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
894
    .value = CODEC_ID_H264,
895
};
896 7402ee23 Diego Biurrun
#endif
897 76d32428 Diego Biurrun
898 b250f9c6 Aurelien Jacobs
#if CONFIG_H264_MUXER
899 76d32428 Diego Biurrun
AVOutputFormat h264_muxer = {
900
    "h264",
901
    NULL_IF_CONFIG_SMALL("raw H.264 video format"),
902
    NULL,
903
    "h264",
904
    0,
905
    CODEC_ID_NONE,
906
    CODEC_ID_H264,
907
    NULL,
908
    raw_write_packet,
909
    .flags= AVFMT_NOTIMESTAMPS,
910
};
911 082f7acf Diego Biurrun
#endif
912 76d32428 Diego Biurrun
913 b250f9c6 Aurelien Jacobs
#if CONFIG_INGENIENT_DEMUXER
914 76d32428 Diego Biurrun
AVInputFormat ingenient_demuxer = {
915
    "ingenient",
916 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
917 76d32428 Diego Biurrun
    0,
918
    NULL,
919
    video_read_header,
920
    ingenient_read_packet,
921
    .flags= AVFMT_GENERIC_INDEX,
922
    .extensions = "cgi", // FIXME
923
    .value = CODEC_ID_MJPEG,
924
};
925 7402ee23 Diego Biurrun
#endif
926 76d32428 Diego Biurrun
927 b250f9c6 Aurelien Jacobs
#if CONFIG_M4V_DEMUXER
928 d2a067d1 Måns Rullgård
AVInputFormat m4v_demuxer = {
929 7866eeff Michael Niedermayer
    "m4v",
930 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
931 7866eeff Michael Niedermayer
    0,
932 fb9f1117 Diego Biurrun
    mpeg4video_probe, /** probing for MPEG-4 data */
933 7866eeff Michael Niedermayer
    video_read_header,
934 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
935 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
936 492322fc Michael Niedermayer
    .extensions = "m4v",
937 bb76a117 Måns Rullgård
    .value = CODEC_ID_MPEG4,
938 7866eeff Michael Niedermayer
};
939 7402ee23 Diego Biurrun
#endif
940 7866eeff Michael Niedermayer
941 b250f9c6 Aurelien Jacobs
#if CONFIG_M4V_MUXER
942 d2a067d1 Måns Rullgård
AVOutputFormat m4v_muxer = {
943 89b3d7c9 Max Krasnyansky
    "m4v",
944 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
945 89b3d7c9 Max Krasnyansky
    NULL,
946
    "m4v",
947
    0,
948
    CODEC_ID_NONE,
949
    CODEC_ID_MPEG4,
950 7a97dd84 Baptiste Coudurier
    NULL,
951 89b3d7c9 Max Krasnyansky
    raw_write_packet,
952 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
953 89b3d7c9 Max Krasnyansky
};
954 082f7acf Diego Biurrun
#endif
955 89b3d7c9 Max Krasnyansky
956 b250f9c6 Aurelien Jacobs
#if CONFIG_MJPEG_DEMUXER
957 76d32428 Diego Biurrun
AVInputFormat mjpeg_demuxer = {
958
    "mjpeg",
959 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw MJPEG video"),
960 0da71265 Michael Niedermayer
    0,
961 76d32428 Diego Biurrun
    NULL,
962 0da71265 Michael Niedermayer
    video_read_header,
963 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
964 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
965 76d32428 Diego Biurrun
    .extensions = "mjpg,mjpeg",
966
    .value = CODEC_ID_MJPEG,
967 0da71265 Michael Niedermayer
};
968 7402ee23 Diego Biurrun
#endif
969 0da71265 Michael Niedermayer
970 b250f9c6 Aurelien Jacobs
#if CONFIG_MJPEG_MUXER
971 76d32428 Diego Biurrun
AVOutputFormat mjpeg_muxer = {
972
    "mjpeg",
973 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw MJPEG video"),
974 76d32428 Diego Biurrun
    "video/x-mjpeg",
975
    "mjpg,mjpeg",
976 0da71265 Michael Niedermayer
    0,
977
    CODEC_ID_NONE,
978 76d32428 Diego Biurrun
    CODEC_ID_MJPEG,
979 7a97dd84 Baptiste Coudurier
    NULL,
980 0da71265 Michael Niedermayer
    raw_write_packet,
981 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
982 0da71265 Michael Niedermayer
};
983 082f7acf Diego Biurrun
#endif
984 0da71265 Michael Niedermayer
985 b250f9c6 Aurelien Jacobs
#if CONFIG_MLP_DEMUXER
986 76d32428 Diego Biurrun
AVInputFormat mlp_demuxer = {
987
    "mlp",
988
    NULL_IF_CONFIG_SMALL("raw MLP"),
989 c9a65ca8 Fabrice Bellard
    0,
990 76d32428 Diego Biurrun
    NULL,
991
    audio_read_header,
992 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
993 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
994 76d32428 Diego Biurrun
    .extensions = "mlp",
995
    .value = CODEC_ID_MLP,
996 de6d9b64 Fabrice Bellard
};
997 7402ee23 Diego Biurrun
#endif
998 de6d9b64 Fabrice Bellard
999 0e1ccdeb Andreas Öman
#if CONFIG_MLP_MUXER
1000 9145021d Ramiro Polla
AVOutputFormat mlp_muxer = {
1001
    "mlp",
1002
    NULL_IF_CONFIG_SMALL("raw MLP"),
1003
    NULL,
1004
    "mlp",
1005
    0,
1006
    CODEC_ID_MLP,
1007
    CODEC_ID_NONE,
1008
    NULL,
1009
    raw_write_packet,
1010
    .flags= AVFMT_NOTIMESTAMPS,
1011
};
1012
#endif
1013
1014 23d9cc45 Ramiro Polla
#if CONFIG_TRUEHD_DEMUXER
1015
AVInputFormat truehd_demuxer = {
1016
    "truehd",
1017
    NULL_IF_CONFIG_SMALL("raw TrueHD"),
1018
    0,
1019
    NULL,
1020
    audio_read_header,
1021
    ff_raw_read_partial_packet,
1022
    .flags= AVFMT_GENERIC_INDEX,
1023
    .extensions = "thd",
1024
    .value = CODEC_ID_TRUEHD,
1025
};
1026
#endif
1027
1028
#if CONFIG_TRUEHD_MUXER
1029
AVOutputFormat truehd_muxer = {
1030
    "truehd",
1031
    NULL_IF_CONFIG_SMALL("raw TrueHD"),
1032
    NULL,
1033
    "thd",
1034
    0,
1035
    CODEC_ID_TRUEHD,
1036
    CODEC_ID_NONE,
1037
    NULL,
1038
    raw_write_packet,
1039
    .flags= AVFMT_NOTIMESTAMPS,
1040
};
1041
#endif
1042
1043 b250f9c6 Aurelien Jacobs
#if CONFIG_MPEG1VIDEO_MUXER
1044 d2a067d1 Måns Rullgård
AVOutputFormat mpeg1video_muxer = {
1045 c9a65ca8 Fabrice Bellard
    "mpeg1video",
1046 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
1047 de6d9b64 Fabrice Bellard
    "video/x-mpeg",
1048 e0827ba4 Michael Niedermayer
    "mpg,mpeg,m1v",
1049 de6d9b64 Fabrice Bellard
    0,
1050 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
1051 de6d9b64 Fabrice Bellard
    CODEC_ID_MPEG1VIDEO,
1052 7a97dd84 Baptiste Coudurier
    NULL,
1053 de6d9b64 Fabrice Bellard
    raw_write_packet,
1054 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
1055 de6d9b64 Fabrice Bellard
};
1056 082f7acf Diego Biurrun
#endif
1057 de6d9b64 Fabrice Bellard
1058 b250f9c6 Aurelien Jacobs
#if CONFIG_MPEG2VIDEO_MUXER
1059 d2a067d1 Måns Rullgård
AVOutputFormat mpeg2video_muxer = {
1060 6ec864da Michael Niedermayer
    "mpeg2video",
1061 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
1062 6ec864da Michael Niedermayer
    NULL,
1063
    "m2v",
1064
    0,
1065 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
1066 6ec864da Michael Niedermayer
    CODEC_ID_MPEG2VIDEO,
1067 7a97dd84 Baptiste Coudurier
    NULL,
1068 6ec864da Michael Niedermayer
    raw_write_packet,
1069 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
1070 6ec864da Michael Niedermayer
};
1071 082f7acf Diego Biurrun
#endif
1072 6ec864da Michael Niedermayer
1073 b250f9c6 Aurelien Jacobs
#if CONFIG_MPEGVIDEO_DEMUXER
1074 76d32428 Diego Biurrun
AVInputFormat mpegvideo_demuxer = {
1075
    "mpegvideo",
1076 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw MPEG video"),
1077 27e084bd Fabrice Bellard
    0,
1078 76d32428 Diego Biurrun
    mpegvideo_probe,
1079 27e084bd Fabrice Bellard
    video_read_header,
1080 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
1081 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
1082 76d32428 Diego Biurrun
    .value = CODEC_ID_MPEG1VIDEO,
1083 27e084bd Fabrice Bellard
};
1084 7402ee23 Diego Biurrun
#endif
1085 27e084bd Fabrice Bellard
1086 9f2fc126 Stefan Gehrer
#if CONFIG_CAVSVIDEO_DEMUXER
1087
AVInputFormat cavsvideo_demuxer = {
1088
    "cavsvideo",
1089 b81350a8 Stefan Gehrer
    NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
1090 9f2fc126 Stefan Gehrer
    0,
1091
    cavsvideo_probe,
1092
    video_read_header,
1093 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
1094 9f2fc126 Stefan Gehrer
    .flags= AVFMT_GENERIC_INDEX,
1095
    .value = CODEC_ID_CAVS,
1096
};
1097
#endif
1098
1099 b250f9c6 Aurelien Jacobs
#if CONFIG_NULL_MUXER
1100 76d32428 Diego Biurrun
AVOutputFormat null_muxer = {
1101
    "null",
1102 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw null video format"),
1103 76d32428 Diego Biurrun
    NULL,
1104
    NULL,
1105 84c63c01 Alex Beregszaszi
    0,
1106 63613fe6 Måns Rullgård
#if HAVE_BIGENDIAN
1107 76d32428 Diego Biurrun
    CODEC_ID_PCM_S16BE,
1108
#else
1109
    CODEC_ID_PCM_S16LE,
1110
#endif
1111
    CODEC_ID_RAWVIDEO,
1112 84c63c01 Alex Beregszaszi
    NULL,
1113 76d32428 Diego Biurrun
    null_write_packet,
1114
    .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
1115
};
1116 082f7acf Diego Biurrun
#endif
1117 76d32428 Diego Biurrun
1118 b250f9c6 Aurelien Jacobs
#if CONFIG_RAWVIDEO_DEMUXER
1119 76d32428 Diego Biurrun
AVInputFormat rawvideo_demuxer = {
1120
    "rawvideo",
1121
    NULL_IF_CONFIG_SMALL("raw video format"),
1122
    0,
1123
    NULL,
1124
    raw_read_header,
1125
    rawvideo_read_packet,
1126 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,
1127 76d32428 Diego Biurrun
    .extensions = "yuv,cif,qcif,rgb",
1128
    .value = CODEC_ID_RAWVIDEO,
1129 84c63c01 Alex Beregszaszi
};
1130 7402ee23 Diego Biurrun
#endif
1131 84c63c01 Alex Beregszaszi
1132 b250f9c6 Aurelien Jacobs
#if CONFIG_RAWVIDEO_MUXER
1133 76d32428 Diego Biurrun
AVOutputFormat rawvideo_muxer = {
1134
    "rawvideo",
1135
    NULL_IF_CONFIG_SMALL("raw video format"),
1136
    NULL,
1137
    "yuv,rgb",
1138 5ed8fafc Fabrice Bellard
    0,
1139 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,
1140 76d32428 Diego Biurrun
    CODEC_ID_RAWVIDEO,
1141 7a97dd84 Baptiste Coudurier
    NULL,
1142 5ed8fafc Fabrice Bellard
    raw_write_packet,
1143 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,
1144 5ed8fafc Fabrice Bellard
};
1145 082f7acf Diego Biurrun
#endif
1146 5ed8fafc Fabrice Bellard
1147 b250f9c6 Aurelien Jacobs
#if CONFIG_ROQ_MUXER
1148 76d32428 Diego Biurrun
AVOutputFormat roq_muxer =
1149
{
1150
    "RoQ",
1151 b4ee1d39 Diego Biurrun
    NULL_IF_CONFIG_SMALL("raw id RoQ format"),
1152 76d32428 Diego Biurrun
    NULL,
1153
    "roq",
1154
    0,
1155
    CODEC_ID_ROQ_DPCM,
1156
    CODEC_ID_ROQ,
1157
    roq_write_header,
1158
    raw_write_packet,
1159
};
1160 082f7acf Diego Biurrun
#endif
1161 76d32428 Diego Biurrun
1162 b250f9c6 Aurelien Jacobs
#if CONFIG_SHORTEN_DEMUXER
1163 76d32428 Diego Biurrun
AVInputFormat shorten_demuxer = {
1164
    "shn",
1165
    NULL_IF_CONFIG_SMALL("raw Shorten"),
1166
    0,
1167
    NULL,
1168
    audio_read_header,
1169 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
1170 76d32428 Diego Biurrun
    .flags= AVFMT_GENERIC_INDEX,
1171
    .extensions = "shn",
1172
    .value = CODEC_ID_SHORTEN,
1173
};
1174 7402ee23 Diego Biurrun
#endif
1175 76d32428 Diego Biurrun
1176 b250f9c6 Aurelien Jacobs
#if CONFIG_VC1_DEMUXER
1177 7bb5c2a6 Kostya Shishkov
AVInputFormat vc1_demuxer = {
1178
    "vc1",
1179 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL("raw VC-1"),
1180 7bb5c2a6 Kostya Shishkov
    0,
1181
    NULL /* vc1_probe */,
1182
    video_read_header,
1183 81f052cb Justin Ruggles
    ff_raw_read_partial_packet,
1184 7bb5c2a6 Kostya Shishkov
    .extensions = "vc1",
1185
    .value = CODEC_ID_VC1,
1186
};
1187 7402ee23 Diego Biurrun
#endif
1188 7bb5c2a6 Kostya Shishkov
1189 fb9f1117 Diego Biurrun
/* PCM formats */
1190 764ef400 Mike Melanson
1191 4986a429 Fabrice Bellard
#define PCMINPUTDEF(name, long_name, ext, codec) \
1192 d2a067d1 Måns Rullgård
AVInputFormat pcm_ ## name ## _demuxer = {\
1193 764ef400 Mike Melanson
    #name,\
1194 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL(long_name),\
1195 764ef400 Mike Melanson
    0,\
1196
    NULL,\
1197
    raw_read_header,\
1198
    raw_read_packet,\
1199 9b64a036 Baptiste Coudurier
    NULL,\
1200 4986a429 Fabrice Bellard
    pcm_read_seek,\
1201 e9b78eeb Michael Niedermayer
    .flags= AVFMT_GENERIC_INDEX,\
1202 764ef400 Mike Melanson
    .extensions = ext,\
1203
    .value = codec,\
1204
};
1205
1206 2c8e2014 Diego Biurrun
#define PCMOUTPUTDEF(name, long_name, ext, codec) \
1207 d2a067d1 Måns Rullgård
AVOutputFormat pcm_ ## name ## _muxer = {\
1208 c9a65ca8 Fabrice Bellard
    #name,\
1209 bde15e74 Stefano Sabatini
    NULL_IF_CONFIG_SMALL(long_name),\
1210 c9a65ca8 Fabrice Bellard
    NULL,\
1211
    ext,\
1212
    0,\
1213
    codec,\
1214 d9133126 Carl Eugen Hoyos
    CODEC_ID_NONE,\
1215 7a97dd84 Baptiste Coudurier
    NULL,\
1216 c9a65ca8 Fabrice Bellard
    raw_write_packet,\
1217 494bbf58 Michael Niedermayer
    .flags= AVFMT_NOTIMESTAMPS,\
1218 5ed8fafc Fabrice Bellard
};
1219 2c8e2014 Diego Biurrun
1220
1221 b250f9c6 Aurelien Jacobs
#if  !CONFIG_MUXERS && CONFIG_DEMUXERS
1222 2c8e2014 Diego Biurrun
#define PCMDEF(name, long_name, ext, codec) \
1223
        PCMINPUTDEF(name, long_name, ext, codec)
1224 b250f9c6 Aurelien Jacobs
#elif CONFIG_MUXERS && !CONFIG_DEMUXERS
1225 2c8e2014 Diego Biurrun
#define PCMDEF(name, long_name, ext, codec) \
1226
        PCMOUTPUTDEF(name, long_name, ext, codec)
1227 b250f9c6 Aurelien Jacobs
#elif CONFIG_MUXERS && CONFIG_DEMUXERS
1228 2c8e2014 Diego Biurrun
#define PCMDEF(name, long_name, ext, codec) \
1229
        PCMINPUTDEF(name, long_name, ext, codec)\
1230
        PCMOUTPUTDEF(name, long_name, ext, codec)
1231
#else
1232
#define PCMDEF(name, long_name, ext, codec)
1233
#endif
1234 5ed8fafc Fabrice Bellard
1235 63613fe6 Måns Rullgård
#if HAVE_BIGENDIAN
1236 c9a65ca8 Fabrice Bellard
#define BE_DEF(s) s
1237
#define LE_DEF(s) NULL
1238 5ed8fafc Fabrice Bellard
#else
1239 c9a65ca8 Fabrice Bellard
#define BE_DEF(s) NULL
1240
#define LE_DEF(s) s
1241 5ed8fafc Fabrice Bellard
#endif
1242
1243 ee7948cb Peter Ross
PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
1244
       NULL, CODEC_ID_PCM_F64BE)
1245
1246
PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
1247
       NULL, CODEC_ID_PCM_F64LE)
1248
1249
PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
1250
       NULL, CODEC_ID_PCM_F32BE)
1251
1252
PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
1253
       NULL, CODEC_ID_PCM_F32LE)
1254
1255
PCMDEF(s32be, "PCM signed 32 bit big-endian format",
1256
       NULL, CODEC_ID_PCM_S32BE)
1257
1258
PCMDEF(s32le, "PCM signed 32 bit little-endian format",
1259
       NULL, CODEC_ID_PCM_S32LE)
1260
1261
PCMDEF(s24be, "PCM signed 24 bit big-endian format",
1262
       NULL, CODEC_ID_PCM_S24BE)
1263
1264
PCMDEF(s24le, "PCM signed 24 bit little-endian format",
1265
       NULL, CODEC_ID_PCM_S24LE)
1266 5ed8fafc Fabrice Bellard
1267 ac1ea66e Diego Biurrun
PCMDEF(s16be, "PCM signed 16 bit big-endian format",
1268 c9a65ca8 Fabrice Bellard
       BE_DEF("sw"), CODEC_ID_PCM_S16BE)
1269 5ed8fafc Fabrice Bellard
1270 76d32428 Diego Biurrun
PCMDEF(s16le, "PCM signed 16 bit little-endian format",
1271
       LE_DEF("sw"), CODEC_ID_PCM_S16LE)
1272
1273
PCMDEF(s8, "PCM signed 8 bit format",
1274
       "sb", CODEC_ID_PCM_S8)
1275 5ed8fafc Fabrice Bellard
1276 ee7948cb Peter Ross
PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
1277
       NULL, CODEC_ID_PCM_U32BE)
1278
1279
PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
1280
       NULL, CODEC_ID_PCM_U32LE)
1281
1282
PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
1283
       NULL, CODEC_ID_PCM_U24BE)
1284
1285
PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
1286
       NULL, CODEC_ID_PCM_U24LE)
1287
1288 ac1ea66e Diego Biurrun
PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
1289 c9a65ca8 Fabrice Bellard
       BE_DEF("uw"), CODEC_ID_PCM_U16BE)
1290 5ed8fafc Fabrice Bellard
1291 76d32428 Diego Biurrun
PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
1292
       LE_DEF("uw"), CODEC_ID_PCM_U16LE)
1293 5ed8fafc Fabrice Bellard
1294 ac1ea66e Diego Biurrun
PCMDEF(u8, "PCM unsigned 8 bit format",
1295 c9a65ca8 Fabrice Bellard
       "ub", CODEC_ID_PCM_U8)
1296 5ed8fafc Fabrice Bellard
1297 ac1ea66e Diego Biurrun
PCMDEF(alaw, "PCM A-law format",
1298 c9a65ca8 Fabrice Bellard
       "al", CODEC_ID_PCM_ALAW)
1299 de6d9b64 Fabrice Bellard
1300 76d32428 Diego Biurrun
PCMDEF(mulaw, "PCM mu-law format",
1301
       "ul", CODEC_ID_PCM_MULAW)