1 /*
2 * Deluxe Paint Animation demuxer
3 * Copyright (c) 2009 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 /**
23 * @file
24 * Deluxe Paint Animation demuxer
25 */
26
30
36
38 unsigned int nb_pages;
/**< total pages in file */
41 #define MAX_PAGES 256 /**< Deluxe Paint hardcoded value */
43 int page;
/**< current page (or AVERROR_xxx code) */
44 int record;
/**< current record (with in page) */
46
47 #define LPF_TAG MKTAG('L','P','F',' ')
48 #define ANIM_TAG MKTAG('A','N','I','M')
49
51 {
52 /* verify tags and video dimensions */
57 return 0;
58 }
59
60 /**
61 * @return page containing the requested record or AVERROR_XXX
62 */
64 {
65 int i;
66
69
71 const Page *p = &anm->
pt[i];
73 return i;
74 }
75
77 }
78
80 {
85
90 }
91
94 avio_skip(pb, 2);
/* max records per page */
98
99 /* video stream */
101 if (!st)
109 goto invalid;
110 avio_skip(pb, 1);
/* frame rate multiplier info */
111
112 /* ignore last delta record (used for looping) */
113 if (
avio_r8(pb))
/* has_last_delta */
115
117
119 goto invalid;
120
122 goto invalid;
123
124 avio_skip(pb, 1);
/* other recs per frame */
125
127 goto invalid;
128
133
134 /* color cycling and palette data */
139 }
141 if (ret < 0)
143
144 /* read page table */
146 if (ret < 0)
148
154 }
155
156 /* find page of first frame */
160 }
161
163 return 0;
164
165 invalid:
168 }
169
172 {
176 int tmp, record_size;
177
180
183
184 repeat:
186
187 /* parse page header */
192 }
193
194 /* if we have fetched all records in this page, then find the
195 next page and repeat */
201 goto repeat;
202 }
203
204 /* fetch record size */
207 8 + anm->
record * 2, SEEK_SET);
210
211 /* fetch record */
217
219 return 0;
220 }
221
229 };