Mercurial > libavformat.hg
annotate filmstripdec.c @ 6356:2048bf728893 libavformat
get ride of MAX_STREAMS limit in RDT
author | aurel |
---|---|
date | Mon, 09 Aug 2010 22:58:54 +0000 |
parents | 178de7695c6c |
children |
rev | line source |
---|---|
5547 | 1 /* |
2 * Adobe Filmstrip demuxer | |
3 * Copyright (c) 2010 Peter Ross | |
4 * | |
5 * This file is part of FFmpeg. | |
6 * | |
7 * FFmpeg is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public | |
9 * License as published by the Free Software Foundation; either | |
10 * version 2.1 of the License, or (at your option) any later version. | |
11 * | |
12 * FFmpeg is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with FFmpeg; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
5969
178de7695c6c
Remove explicit filename from Doxygen @file commands.
diego
parents:
5913
diff
changeset
|
23 * @file |
5547 | 24 * Adobe Filmstrip demuxer |
25 */ | |
26 | |
27 #include "libavutil/intreadwrite.h" | |
28 #include "avformat.h" | |
29 | |
30 #define RAND_TAG MKBETAG('R','a','n','d') | |
31 | |
32 typedef struct { | |
33 int leading; | |
34 } FilmstripDemuxContext; | |
35 | |
36 static int read_header(AVFormatContext *s, | |
37 AVFormatParameters *ap) | |
38 { | |
39 FilmstripDemuxContext *film = s->priv_data; | |
40 ByteIOContext *pb = s->pb; | |
41 AVStream *st; | |
42 | |
43 if (url_is_streamed(s->pb)) | |
44 return AVERROR(EIO); | |
45 | |
46 url_fseek(pb, url_fsize(pb) - 36, SEEK_SET); | |
47 if (get_be32(pb) != RAND_TAG) { | |
48 av_log(s, AV_LOG_ERROR, "magic number not found"); | |
49 return AVERROR_INVALIDDATA; | |
50 } | |
51 | |
52 st = av_new_stream(s, 0); | |
53 if (!st) | |
54 return AVERROR(ENOMEM); | |
55 | |
56 st->nb_frames = get_be32(pb); | |
57 if (get_be16(pb) != 0) { | |
58 av_log_ask_for_sample(s, "unsupported packing method\n"); | |
59 return AVERROR_INVALIDDATA; | |
60 } | |
61 | |
62 url_fskip(pb, 2); | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5547
diff
changeset
|
63 st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
5547 | 64 st->codec->codec_id = CODEC_ID_RAWVIDEO; |
65 st->codec->pix_fmt = PIX_FMT_RGBA; | |
66 st->codec->codec_tag = 0; /* no fourcc */ | |
67 st->codec->width = get_be16(pb); | |
68 st->codec->height = get_be16(pb); | |
69 film->leading = get_be16(pb); | |
70 av_set_pts_info(st, 64, 1, get_be16(pb)); | |
71 | |
72 url_fseek(pb, 0, SEEK_SET); | |
73 | |
74 return 0; | |
75 } | |
76 | |
77 static int read_packet(AVFormatContext *s, | |
78 AVPacket *pkt) | |
79 { | |
80 FilmstripDemuxContext *film = s->priv_data; | |
81 AVStream *st = s->streams[0]; | |
82 | |
83 if (url_feof(s->pb)) | |
84 return AVERROR(EIO); | |
85 pkt->dts = url_ftell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4); | |
86 pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4); | |
87 url_fskip(s->pb, st->codec->width * film->leading * 4); | |
88 if (pkt->size < 0) | |
89 return pkt->size; | |
5913
11bb10c37225
Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
cehoyos
parents:
5910
diff
changeset
|
90 pkt->flags |= AV_PKT_FLAG_KEY; |
5547 | 91 return 0; |
92 } | |
93 | |
94 static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) | |
95 { | |
96 AVStream *st = s->streams[stream_index]; | |
97 url_fseek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET); | |
98 return 0; | |
99 } | |
100 | |
101 AVInputFormat filmstrip_demuxer = { | |
102 "filmstrip", | |
103 NULL_IF_CONFIG_SMALL("Adobe Filmstrip"), | |
104 sizeof(FilmstripDemuxContext), | |
105 NULL, | |
106 read_header, | |
107 read_packet, | |
108 NULL, | |
109 read_seek, | |
110 .extensions = "flm", | |
111 }; |