annotate ingenientdec.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 4775a49a6045
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
1 /*
6430
d3a51b32b769 move ingenient demuxer to its own file
aurel
parents: 6429
diff changeset
2 * RAW Ingenient MJPEG demuxer
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
3 * Copyright (c) 2005 Alex Beregszaszi
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 887
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3274
diff changeset
21
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include "avformat.h"
6448
4775a49a6045 split raw.c into rawdec.c and rawenc.c
aurel
parents: 6430
diff changeset
23 #include "rawdec.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
25 // http://www.artificis.hu/files/texts/ingenient.txt
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
26 static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
27 {
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
28 int ret, size, w, h, unk1, unk2;
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
29
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
30 if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
31 return AVERROR(EIO); // FIXME
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
32
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
33 size = get_le32(s->pb);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
34
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
35 w = get_le16(s->pb);
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
36 h = get_le16(s->pb);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
37
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
38 url_fskip(s->pb, 8); // zero + size (padded?)
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
39 url_fskip(s->pb, 2);
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
40 unk1 = get_le16(s->pb);
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
41 unk2 = get_le16(s->pb);
3725
900a232fc55e cosmetics: misc spelling fixes
diego
parents: 3613
diff changeset
42 url_fskip(s->pb, 22); // ASCII timestamp
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
43
4510
6d77b56e2b0e Add a context to av_log() call.
benoit
parents: 4501
diff changeset
44 av_log(s, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n",
887
d70e50f1495f COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 885
diff changeset
45 size, w, h, unk1, unk2);
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
46
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
47 if (av_new_packet(pkt, size) < 0)
5245
30c093f11b4e av_new_packet failing should return ENOMEM, not EIO.
reimar
parents: 5238
diff changeset
48 return AVERROR(ENOMEM);
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
49
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
50 pkt->pos = url_ftell(s->pb);
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
51 pkt->stream_index = 0;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
52 ret = get_buffer(s->pb, pkt->data, size);
5254
83cc2a571542 Return any error return values from av_get_packet, get_buffer etc. unchanged
reimar
parents: 5249
diff changeset
53 if (ret < 0) {
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
54 av_free_packet(pkt);
5254
83cc2a571542 Return any error return values from av_get_packet, get_buffer etc. unchanged
reimar
parents: 5249
diff changeset
55 return ret;
868
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
56 }
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
57 pkt->size = ret;
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
58 return ret;
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
59 }
c6b1dde68f3a Ingenient MJPEG support, more at http://www.artificis.hu/files/texts/ingenient.txt
alex
parents: 858
diff changeset
60
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
61 AVInputFormat ingenient_demuxer = {
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
62 "ingenient",
4501
3e5b9c1a413e Make format long_names consistent.
diego
parents: 4293
diff changeset
63 NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"),
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
64 0,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
65 NULL,
6430
d3a51b32b769 move ingenient demuxer to its own file
aurel
parents: 6429
diff changeset
66 ff_raw_video_read_header,
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
67 ingenient_read_packet,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
68 .flags= AVFMT_GENERIC_INDEX,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
69 .extensions = "cgi", // FIXME
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
70 .value = CODEC_ID_MJPEG,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
71 };