1 /*
2 * Sega FILM Format (CPK) Demuxer
3 * Copyright (c) 2003 The FFmpeg Project
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 * Sega FILM (.cpk) file demuxer
25 * by Mike Melanson (melanson@pcisys.net)
26 * For more information regarding the Sega FILM file format, visit:
27 * http://www.pcisys.net/~melanson/codecs/
28 */
29
34
35 #define FILM_TAG MKBETAG('F', 'I', 'L', 'M')
36 #define FDSC_TAG MKBETAG('F', 'D', 'S', 'C')
37 #define STAB_TAG MKBETAG('S', 'T', 'A', 'B')
38 #define CVID_TAG MKBETAG('c', 'v', 'i', 'd')
39 #define RAW_TAG MKBETAG('r', 'a', 'w', ' ')
40
48
52
57
62
66
68 {
70 return 0;
71
73 return 0;
74
76 }
77
79 {
81
83
84 return 0;
85 }
86
88 {
92 unsigned char scratch[256];
94 unsigned int data_offset;
95 unsigned int audio_frame_counter;
96
98
99 /* load the main FILM header */
102 data_offset =
AV_RB32(&scratch[4]);
104
105 /* load the FDSC chunk */
107 /* special case for Lemmings .film files; 20-byte header */
110 /* make some assumptions about the audio parameters */
115 } else {
116 /* normal Saturn .cpk files; 32-byte header */
129 else
131 } else
133 }
134
137
142 } else {
144 }
145
146 /* initialize the decoder streams */
149 if (!st)
157
159 if (scratch[20] == 24) {
161 } else {
163 return -1;
164 }
165 }
166 }
167
170 if (!st)
178
183 } else {
187 }
188
191 }
192
193 /* load the sample table */
201 return -1;
205
210 else
212 }
213
214 audio_frame_counter = 0;
216 /* load the next sample record and transfer it to an internal struct */
219 goto fail;
220 }
222 data_offset +
AV_RB32(&scratch[0]);
226 goto fail;
227 }
228 if (
AV_RB32(&scratch[8]) == 0xFFFFFFFF) {
231
238 } else {
242 }
243 }
244
246
247 return 0;
248 fail:
251 }
252
255 {
260
263
265
266 /* position the stream (will probably be there anyway) */
268
269
273
276
278
280 }
281
290 };