FFmpeg: libavformat/mvdec.c Source File
Go to the documentation of this file. 1 /*
2 * Silicon Graphics Movie demuxer
3 * Copyright (c) 2012 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 * Silicon Graphics Movie demuxer
25 */
26
33
37
41
42 int eof_count;
///< number of streams that have finished
44 int frame[2];
///< frame nb for current stream
45
49
50 /* these magic numbers are defined in moviefile.h on Silicon Graphics IRIX */
52 #define MOVIE_SILENT 2
53
54 #define AUDIO_FORMAT_SIGNED 401
55
57 {
61 return 0;
62 }
63
65 {
66 int n;
67 char *str;
68
71
73 if (!str)
78 return str;
79 }
80
82 {
83 int v;
86 return 0;
87 v = strtol(
s,
NULL, 10);
89 return v;
90 }
91
93 {
100 return v;
101 }
102
104 {
108 }
109
111 {
115 }
117 return 0;
118 }
119
120 /**
121 * Parse global variable
122 * @return < 0 if unknown
123 */
126 {
129 if (!strcmp(
name,
"__NUM_I_TRACKS")) {
131 }
else if (!strcmp(
name,
"__NUM_A_TRACKS")) {
133 }
else if (!strcmp(
name,
"COMMENT") || !strcmp(
name,
"TITLE")) {
135 }
else if (!strcmp(
name,
"LOOP_MODE") || !strcmp(
name,
"NUM_LOOPS") ||
136 !strcmp(
name,
"OPTIMIZED")) {
138 } else
140
141 return 0;
142 }
143
144 /**
145 * Parse audio variable
146 * @return < 0 if unknown
147 */
150 {
153 if (!strcmp(
name,
"__DIR_COUNT")) {
155 }
else if (!strcmp(
name,
"AUDIO_FORMAT")) {
157 }
else if (!strcmp(
name,
"COMPRESSION")) {
159 }
else if (!strcmp(
name,
"DEFAULT_VOL")) {
161 }
else if (!strcmp(
name,
"NUM_CHANNELS")) {
163 }
else if (!strcmp(
name,
"SAMPLE_RATE")) {
165 if (sample_rate <= 0)
169 }
else if (!strcmp(
name,
"SAMPLE_WIDTH")) {
171 if (bpc > 16)
174 } else
176
177 return 0;
178 }
179
180 /**
181 * Parse video variable
182 * @return < 0 if unknown
183 */
186 {
188 if (!strcmp(
name,
"__DIR_COUNT")) {
190 }
else if (!strcmp(
name,
"COMPRESSION")) {
192 if (!str)
194 if (!strcmp(str, "1")) {
196 } else if (!strcmp(str, "2")) {
199 } else if (!strcmp(str, "3")) {
201 } else if (!strcmp(str, "10")) {
203 } else if (!strcmp(str, "MVC2")) {
205 } else {
207 }
209 }
else if (!strcmp(
name,
"FPS")) {
213 }
else if (!strcmp(
name,
"HEIGHT")) {
215 }
else if (!strcmp(
name,
"PIXEL_ASPECT")) {
219 INT_MAX);
220 }
else if (!strcmp(
name,
"WIDTH")) {
222 }
else if (!strcmp(
name,
"ORIENTATION")) {
229 }
230 }
231 }
else if (!strcmp(
name,
"Q_SPATIAL") || !strcmp(
name,
"Q_TEMPORAL")) {
233 }
else if (!strcmp(
name,
"INTERLACING") || !strcmp(
name,
"PACKING")) {
235 } else
237
238 return 0;
239 }
240
244 {
245 unsigned count;
247
252 for (
i = 0;
i < count;
i++) {
255
258
266 }
270 }
271 }
272 return 0;
273 }
274
276 {
277 uint64_t timestamp = 0;
288 } else {
289 timestamp++;
290 }
291 }
292 }
293
295 {
301
303
306 uint64_t timestamp;
307 int v;
308 uint32_t bytes_per_sample;
310
312
314
315 /* allocate audio track first to prevent unnecessary seeking
316 * (audio packet always precede video packet for a given frame) */
319 /* movie has sound so allocate an audio stream */
321 if (!ast)
325
327
329 if (!vst)
333 vst->avg_frame_rate = fps;
334 vst->duration = vst->nb_frames =
avio_rb32(pb);
336 switch (v) {
337 case 1:
339 break;
340 case 2:
343 break;
344 default:
346 break;
347 }
348 vst->codecpar->codec_tag = 0;
352
353 if (ast) {
360 }
362
364
367 switch (bytes_per_sample) {
368 case 1:
370 break;
371 case 2:
373 break;
374 default:
376 break;
377 }
378 } else {
380 }
381
382 if (bytes_per_sample == 0)
384
387
389 } else
390 avio_skip(pb, 24);
/* skip meaningless audio metadata */
391
395
396 timestamp = 0;
397 for (
i = 0;
i < vst->nb_frames;
i++) {
404 if (ast) {
407 }
409 }
412
415
416 if (
mv->nb_audio_tracks < 0 ||
mv->nb_video_tracks < 0 ||
417 (
mv->nb_audio_tracks == 0 &&
mv->nb_video_tracks == 0)) {
420 }
421
422 if (
mv->nb_audio_tracks > 1) {
425 }
else if (
mv->nb_audio_tracks) {
427 if (!ast)
432 if (
mv->acompression == 100 &&
436 } else {
438 "Audio compression %i (format %i, sr %i)",
439 mv->acompression,
mv->aformat,
442 }
446 }
447 }
448
449 if (
mv->nb_video_tracks > 1) {
452 }
else if (
mv->nb_video_tracks) {
454 if (!vst)
459 }
460
461 if (
mv->nb_audio_tracks)
463
464 if (
mv->nb_video_tracks)
466 } else {
469 }
470
471 return 0;
472 }
473
475 {
484
485 if (frame < sti->nb_index_entries) {
496 }
500
504
505 mv->frame[
mv->stream_index]++;
507 } else {
511
512 // avoid returning 0 without a packet
514 }
515
518 mv->stream_index = 0;
519
520 return 0;
521 }
522
525 {
529
532
535
539
542 return 0;
543 }
544
553 };
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
int eof_count
number of streams that have finished
int frame[2]
frame nb for current stream
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
enum AVMediaType codec_type
General type of the encoded data.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static char * var_read_string(AVIOContext *pb, int size)
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
static const int8_t mv[256][2]
AVStream ** streams
A list of all streams in the file.
AVRational avg_frame_rate
Average framerate.
int nb_channels
Number of channels in this layout.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
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.
#define AUDIO_FORMAT_SIGNED
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t duration
Decoding: duration of the stream, in stream time base.
static int var_read_int(AVIOContext *pb, int size)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse audio variable.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static void var_read_metadata(AVFormatContext *avctx, const char *tag, int size)
Rational number (pair of numerator and denominator).
static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
uint64_t avio_rb64(AVIOContext *s)
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse video variable.
AVChannelLayout ch_layout
Audio only.
static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse global variable.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int stream_index
current stream index
int sample_rate
Audio only.
int64_t nb_frames
number of frames in this stream if known or 0
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
#define MKBETAG(a, b, c, d)
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
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int flags
A combination of AV_PKT_FLAG values.
static int read_header(FFV1Context *f, RangeCoder *c)
static int mv_probe(const AVProbeData *p)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
static int mv_read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
#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...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static void read_index(AVIOContext *pb, AVStream *st)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
unsigned int avio_rb16(AVIOContext *s)
static int mv_read_header(AVFormatContext *avctx)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
char * av_strdup(const char *s)
Duplicate a string.
static int read_probe(const AVProbeData *p)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
#define avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int acompression
compression level for audio stream
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static int read_table(AVFormatContext *avctx, AVStream *st, int(*parse)(AVFormatContext *avctx, AVStream *st, const char *name, int size))
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static AVRational var_read_float(AVIOContext *pb, int size)
const FFInputFormat ff_mv_demuxer
void * priv_data
Format private data.
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.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Wed Nov 19 2025 19:23:18 for FFmpeg by
doxygen
1.8.17