annotate iv8.c @ 5404:0b4951f549d4 libavformat

use AVFormatContext in av_log, better than AVCodecContext when multiple streams are present
author bcoudurier
date Tue, 01 Dec 2009 20:15:05 +0000
parents e92aec1db0b9
children 4e1430703688
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
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
47 st->codec->codec_type = CODEC_TYPE_VIDEO;
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 {
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
58 int ret, size, pts;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
59
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
60 get_be16(s->pb); // 257
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
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
72 ret= av_get_packet(s->pb, pkt, size);
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
73
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
74 pkt->pts= pkt->dts= pts;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
75 pkt->pos-=16;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
76
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
77 pkt->stream_index = 0;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
78
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
79 return ret;
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
80 }
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 AVInputFormat iv8_demuxer = {
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
83 "iv8",
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
84 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
85 0,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
86 probe,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
87 read_header,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
88 read_packet,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
89 .flags= AVFMT_GENERIC_INDEX,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
90 .value = CODEC_ID_MPEG4,
e92aec1db0b9 Support "A format generated by IndigoVision 8000 video server".
michael
parents:
diff changeset
91 };