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
32
35
39
40 int eof_count;
///< number of streams that have finished
42 int frame[2];
///< frame nb for current stream
43
47
48 /* these magic numbers are defined in moviefile.h on Silicon Grahpics IRIX */
50 #define MOVIE_SILENT 2
51
52 #define AUDIO_FORMAT_SIGNED 401
53
55 {
59 return 0;
60 }
61
63 {
64 int n;
66
69
77 }
78
80 {
81 int v;
84 return 0;
85 v = strtol(
s,
NULL, 10);
87 return v;
88 }
89
91 {
98 return v;
99 }
100
102 {
106 }
107
109 {
113 }
115 return 0;
116 }
117
118 /**
119 * Parse global variable
120 * @return < 0 if unknown
121 */
124 {
127 if (!strcmp(
name,
"__NUM_I_TRACKS")) {
129 }
else if (!strcmp(
name,
"__NUM_A_TRACKS")) {
131 }
else if (!strcmp(
name,
"COMMENT") || !strcmp(
name,
"TITLE")) {
133 }
else if (!strcmp(
name,
"LOOP_MODE") || !strcmp(
name,
"NUM_LOOPS") ||
134 !strcmp(
name,
"OPTIMIZED")) {
136 } else
138
139 return 0;
140 }
141
142 /**
143 * Parse audio variable
144 * @return < 0 if unknown
145 */
148 {
151 if (!strcmp(
name,
"__DIR_COUNT")) {
153 }
else if (!strcmp(
name,
"AUDIO_FORMAT")) {
155 }
else if (!strcmp(
name,
"COMPRESSION")) {
157 }
else if (!strcmp(
name,
"DEFAULT_VOL")) {
159 }
else if (!strcmp(
name,
"NUM_CHANNELS")) {
161 }
else if (!strcmp(
name,
"SAMPLE_RATE")) {
167 }
else if (!strcmp(
name,
"SAMPLE_WIDTH")) {
169 if (bpc > 16)
172 } else
174
175 return 0;
176 }
177
178 /**
179 * Parse video variable
180 * @return < 0 if unknown
181 */
184 {
186 if (!strcmp(
name,
"__DIR_COUNT")) {
188 }
else if (!strcmp(
name,
"COMPRESSION")) {
192 if (!strcmp(
str,
"1")) {
194 }
else if (!strcmp(
str,
"2")) {
197 }
else if (!strcmp(
str,
"3")) {
199 }
else if (!strcmp(
str,
"10")) {
201 }
else if (!strcmp(
str,
"MVC2")) {
203 } else {
205 }
207 }
else if (!strcmp(
name,
"FPS")) {
211 }
else if (!strcmp(
name,
"HEIGHT")) {
213 }
else if (!strcmp(
name,
"PIXEL_ASPECT")) {
217 INT_MAX);
218 }
else if (!strcmp(
name,
"WIDTH")) {
220 }
else if (!strcmp(
name,
"ORIENTATION")) {
227 }
228 }
229 }
else if (!strcmp(
name,
"Q_SPATIAL") || !strcmp(
name,
"Q_TEMPORAL")) {
231 }
else if (!strcmp(
name,
"INTERLACING") || !strcmp(
name,
"PACKING")) {
233 } else
235
236 return 0;
237 }
238
242 {
243 unsigned count;
245
250 for (
i = 0;
i < count;
i++) {
253
256
263 }
267 }
268 }
269 return 0;
270 }
271
273 {
274 uint64_t timestamp = 0;
285 } else {
286 timestamp++;
287 }
288 }
289 }
290
292 {
298
300
303 uint64_t timestamp;
304 int v;
305 uint32_t bytes_per_sample;
307
309
311
312 /* allocate audio track first to prevent unnecessary seeking
313 * (audio packet always precede video packet for a given frame) */
316 /* movie has sound so allocate an audio stream */
318 if (!ast)
322
324
326 if (!vst)
330 vst->avg_frame_rate = fps;
331 vst->duration = vst->nb_frames =
avio_rb32(pb);
333 switch (v) {
334 case 1:
336 break;
337 case 2:
340 break;
341 default:
343 break;
344 }
345 vst->codecpar->codec_tag = 0;
349
350 if (ast) {
357 }
359
361
364 switch (bytes_per_sample) {
365 case 1:
367 break;
368 case 2:
370 break;
371 default:
373 break;
374 }
375 } else {
377 }
378
379 if (bytes_per_sample == 0)
381
384
386 } else
387 avio_skip(pb, 24);
/* skip meaningless audio metadata */
388
392
393 timestamp = 0;
394 for (
i = 0;
i < vst->nb_frames;
i++) {
401 if (ast) {
404 }
406 }
409
412
413 if (
mv->nb_audio_tracks < 0 ||
mv->nb_video_tracks < 0 ||
414 (
mv->nb_audio_tracks == 0 &&
mv->nb_video_tracks == 0)) {
417 }
418
419 if (
mv->nb_audio_tracks > 1) {
422 }
else if (
mv->nb_audio_tracks) {
424 if (!ast)
429 if (
mv->acompression == 100 &&
433 } else {
435 "Audio compression %i (format %i, sr %i)",
436 mv->acompression,
mv->aformat,
439 }
443 }
444 }
445
446 if (
mv->nb_video_tracks > 1) {
449 }
else if (
mv->nb_video_tracks) {
451 if (!vst)
456 }
457
458 if (
mv->nb_audio_tracks)
460
461 if (
mv->nb_video_tracks)
463 } else {
466 }
467
468 return 0;
469 }
470
472 {
481
482 if (frame < sti->nb_index_entries) {
493 }
497
501
502 mv->frame[
mv->stream_index]++;
504 } else {
508
509 // avoid returning 0 without a packet
511 }
512
515 mv->stream_index = 0;
516
517 return 0;
518 }
519
521 int64_t timestamp,
int flags)
522 {
526
529
532
536
539 return 0;
540 }
541
550 };
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
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 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.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
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)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int read_header(FFV1Context *f)
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.
@ 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.
const AVInputFormat ff_mv_demuxer
#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 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.
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 flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static AVRational var_read_float(AVIOContext *pb, int size)
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 Tue Feb 28 2023 21:34:07 for FFmpeg by
doxygen
1.8.17