FFmpeg: libavformat/segafilm.c Source File
Go to the documentation of this file. 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 unsigned int video_frame_counter;
97
99
100 /* load the main FILM header */
103 data_offset =
AV_RB32(&scratch[4]);
105
106 /* load the FDSC chunk */
108 /* special case for Lemmings .film files; 20-byte header */
111 /* make some assumptions about the audio parameters */
116 } else {
117 /* normal Saturn .cpk files; 32-byte header */
130 else
132 } else
134 }
135
138
143 } else {
145 }
146
149
150 /* initialize the decoder streams */
153 if (!st)
161
163 if (scratch[20] == 24) {
165 } else {
167 return -1;
168 }
169 }
170 }
171
174 if (!st)
182
187 } else {
191 }
192
195 }
196
197 /* load the sample table */
207
208 for (
i = 0;
i <
s->nb_streams;
i++) {
212 else
214 }
215
216 audio_frame_counter = video_frame_counter = 0;
218 /* load the next sample record and transfer it to an internal struct */
222 data_offset +
AV_RB32(&scratch[0]);
226 if (
AV_RB32(&scratch[8]) == 0xFFFFFFFF) {
229
236 } else {
240 video_frame_counter++;
247 }
248 }
249
252
255
257
258 return 0;
259 }
260
263 {
268 int next_sample_id;
270
273
275
276 /* Find the next sample from the same stream, assuming there is one;
277 * this is used to calculate the duration below */
279 while (next_sample ==
NULL) {
281 break;
282
286 next_sample_id++;
287 }
288 }
289
290 /* position the stream (will probably be there anyway) */
292
296
301 if (next_sample !=
NULL)
303
305
307 }
308
310 {
317
321
323
324 return 0;
325 }
326
337 };
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
#define AVERROR_EOF
End of file.
static int film_read_packet(AVFormatContext *s, AVPacket *pkt)
@ AV_CODEC_ID_PCM_S16BE_PLANAR
unsigned int sample_count
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
unsigned int audio_channels
int nb_channels
Number of channels in this layout.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static av_cold int read_close(AVFormatContext *ctx)
unsigned int audio_samplerate
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int film_read_header(AVFormatContext *s)
enum AVStreamParseType need_parsing
static int film_probe(const AVProbeData *p)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
This structure contains the data a format has to probe a file.
unsigned int current_sample
film_sample * sample_table
AVChannelLayout ch_layout
Audio only.
static int film_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
enum AVCodecID video_type
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int film_read_close(AVFormatContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int flags
A combination of AV_PKT_FLAG values.
const AVInputFormat ff_segafilm_demuxer
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int block_align
Audio only.
#define av_malloc_array(a, b)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int index
stream index in AVFormatContext
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
@ AV_CODEC_ID_PCM_S8_PLANAR
#define flags(name, subs,...)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
enum AVCodecID audio_type
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Generated on Wed Aug 24 2022 21:42:20 for FFmpeg by
doxygen
1.8.17