annotate iv8.c @ 6491:b7f807b4cd88 libavformat tip

In mov demuxer, check that nb_streams is valid before using it in read_dac3
author bcoudurier
date Tue, 28 Sep 2010 00:33:21 +0000
parents 536e5527c1e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5398
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
1 /*
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
2 * Copyright (c) 2009 Michael Niedermayer
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
3 *
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
4 * This file is part of FFmpeg.
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
5 *
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
10 *
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
14 * Lesser General Public License for more details.
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
15 *
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
19 */
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
20
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
21 #include "avformat.h"
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
22
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
23
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
24 static int probe(AVProbeData *p)
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
25 {
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
26 // the single file i have starts with that, i dont know if others do too
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
27 if( p->buf[0] == 1
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
28 && p->buf[1] == 1
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
29 && p->buf[2] == 3
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
30 && p->buf[3] == 0xB8
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
31 && p->buf[4] == 0x80
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
32 && p->buf[5] == 0x60
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
33 )
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
34 return AVPROBE_SCORE_MAX-2;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
35
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
36 return 0;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
37 }
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
38
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
39 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
40 {
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
41 AVStream *st;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
42
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
43 st = av_new_stream(s, 0);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
44 if (!st)
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
45 return AVERROR(ENOMEM);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
46
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5650
diff changeset
47 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
5398
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
48 st->codec->codec_id = CODEC_ID_MPEG4;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
49 st->need_parsing = AVSTREAM_PARSE_FULL;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
50 av_set_pts_info(st, 64, 1, 90000);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
51
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
52 return 0;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
53
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
54 }
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
55
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
56 static int read_packet(AVFormatContext *s, AVPacket *pkt)
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
57 {
5650
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
58 int ret, size, pts, type;
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
59 retry:
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
60 type= get_be16(s->pb); // 257 or 258
5398
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
61 size= get_be16(s->pb);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
62
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
63 get_be16(s->pb); //some flags, 0x80 indicates end of frame
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
64 get_be16(s->pb); //packet number
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
65 pts=get_be32(s->pb);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
66 get_be32(s->pb); //6A 13 E3 88
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
67
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
68 size -= 12;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
69 if(size<1)
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
70 return -1;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
71
5650
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
72 if(type==258){
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
73 url_fskip(s->pb, size);
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
74 goto retry;
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
75 }
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
76
5398
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
77 ret= av_get_packet(s->pb, pkt, size);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
78
5650
4e1430703688 Fix timestamps.
michael
parents: 5398
diff changeset
79 pkt->pts= pts;
5398
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
80 pkt->pos-=16;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
81
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
82 pkt->stream_index = 0;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
83
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
84 return ret;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
85 }
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
86
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
87 AVInputFormat iv8_demuxer = {
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
88 "iv8",
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
89 NULL_IF_CONFIG_SMALL("A format generated by IndigoVision 8000 video server"),
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
90 0,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
91 probe,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
92 read_header,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
93 read_packet,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
94 .flags= AVFMT_GENERIC_INDEX,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
95 .value = CODEC_ID_MPEG4,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
96 };