Statistics
| Branch: | Revision:

ffmpeg / libavformat / raw.c @ 470bce2b

History | View | Annotate | Download (29.2 KB)

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