FFmpeg
mvdec.c
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 
28 #include "libavutil/eval.h"
29 #include "libavutil/intfloat.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/rational.h"
32 
33 #include "avformat.h"
34 #include "internal.h"
35 
36 typedef struct MvContext {
39 
40  int eof_count; ///< number of streams that have finished
41  int stream_index; ///< current stream index
42  int frame[2]; ///< frame nb for current stream
43 
44  int acompression; ///< compression level for audio stream
45  int aformat; ///< audio format
46 } MvContext;
47 
48 /* these magic numbers are defined in moviefile.h on Silicon Grahpics IRIX */
49 #define MOVIE_SOUND 1
50 #define MOVIE_SILENT 2
51 
52 #define AUDIO_FORMAT_SIGNED 401
53 
54 static int mv_probe(const AVProbeData *p)
55 {
56  if (AV_RB32(p->buf) == MKBETAG('M', 'O', 'V', 'I') &&
57  AV_RB16(p->buf + 4) < 3)
58  return AVPROBE_SCORE_MAX;
59  return 0;
60 }
61 
62 static char *var_read_string(AVIOContext *pb, int size)
63 {
64  int n;
65  char *str;
66 
67  if (size < 0 || size == INT_MAX)
68  return NULL;
69 
70  str = av_malloc(size + 1);
71  if (!str)
72  return NULL;
73  n = avio_get_str(pb, size, str, size + 1);
74  if (n < size)
75  avio_skip(pb, size - n);
76  return str;
77 }
78 
79 static int var_read_int(AVIOContext *pb, int size)
80 {
81  int v;
82  char *s = var_read_string(pb, size);
83  if (!s)
84  return 0;
85  v = strtol(s, NULL, 10);
86  av_free(s);
87  return v;
88 }
89 
91 {
92  AVRational v;
93  char *s = var_read_string(pb, size);
94  if (!s)
95  return (AVRational) { 0, 0 };
96  v = av_d2q(av_strtod(s, NULL), INT_MAX);
97  av_free(s);
98  return v;
99 }
100 
101 static void var_read_metadata(AVFormatContext *avctx, const char *tag, int size)
102 {
103  char *value = var_read_string(avctx->pb, size);
104  if (value)
106 }
107 
108 static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
109 {
110  if (channels <= 0) {
111  av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid.\n", channels);
112  return AVERROR_INVALIDDATA;
113  }
114  st->codecpar->channels = channels;
117  return 0;
118 }
119 
120 /**
121  * Parse global variable
122  * @return < 0 if unknown
123  */
125  const char *name, int size)
126 {
127  MvContext *mv = avctx->priv_data;
128  AVIOContext *pb = avctx->pb;
129  if (!strcmp(name, "__NUM_I_TRACKS")) {
130  mv->nb_video_tracks = var_read_int(pb, size);
131  } else if (!strcmp(name, "__NUM_A_TRACKS")) {
132  mv->nb_audio_tracks = var_read_int(pb, size);
133  } else if (!strcmp(name, "COMMENT") || !strcmp(name, "TITLE")) {
134  var_read_metadata(avctx, name, size);
135  } else if (!strcmp(name, "LOOP_MODE") || !strcmp(name, "NUM_LOOPS") ||
136  !strcmp(name, "OPTIMIZED")) {
137  avio_skip(pb, size); // ignore
138  } else
139  return AVERROR_INVALIDDATA;
140 
141  return 0;
142 }
143 
144 /**
145  * Parse audio variable
146  * @return < 0 if unknown
147  */
148 static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
149  const char *name, int size)
150 {
151  MvContext *mv = avctx->priv_data;
152  AVIOContext *pb = avctx->pb;
153  if (!strcmp(name, "__DIR_COUNT")) {
154  st->nb_frames = var_read_int(pb, size);
155  } else if (!strcmp(name, "AUDIO_FORMAT")) {
156  mv->aformat = var_read_int(pb, size);
157  } else if (!strcmp(name, "COMPRESSION")) {
158  mv->acompression = var_read_int(pb, size);
159  } else if (!strcmp(name, "DEFAULT_VOL")) {
160  var_read_metadata(avctx, name, size);
161  } else if (!strcmp(name, "NUM_CHANNELS")) {
162  return set_channels(avctx, st, var_read_int(pb, size));
163  } else if (!strcmp(name, "SAMPLE_RATE")) {
164  int sample_rate = var_read_int(pb, size);
165  if (sample_rate <= 0)
166  return AVERROR_INVALIDDATA;
168  avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
169  } else if (!strcmp(name, "SAMPLE_WIDTH")) {
170  uint64_t bpc = var_read_int(pb, size) * (uint64_t)8;
171  if (bpc > 16)
172  return AVERROR_INVALIDDATA;
173  st->codecpar->bits_per_coded_sample = bpc;
174  } else
175  return AVERROR_INVALIDDATA;
176 
177  return 0;
178 }
179 
180 /**
181  * Parse video variable
182  * @return < 0 if unknown
183  */
184 static int parse_video_var(AVFormatContext *avctx, AVStream *st,
185  const char *name, int size)
186 {
187  AVIOContext *pb = avctx->pb;
188  if (!strcmp(name, "__DIR_COUNT")) {
189  st->nb_frames = st->duration = var_read_int(pb, size);
190  } else if (!strcmp(name, "COMPRESSION")) {
191  char *str = var_read_string(pb, size);
192  if (!str)
193  return AVERROR_INVALIDDATA;
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 {
206  avpriv_request_sample(avctx, "Video compression %s", str);
207  }
208  av_free(str);
209  } else if (!strcmp(name, "FPS")) {
210  AVRational fps = var_read_float(pb, size);
211  avpriv_set_pts_info(st, 64, fps.den, fps.num);
212  st->avg_frame_rate = fps;
213  } else if (!strcmp(name, "HEIGHT")) {
214  st->codecpar->height = var_read_int(pb, size);
215  } else if (!strcmp(name, "PIXEL_ASPECT")) {
219  INT_MAX);
220  } else if (!strcmp(name, "WIDTH")) {
221  st->codecpar->width = var_read_int(pb, size);
222  } else if (!strcmp(name, "ORIENTATION")) {
223  if (var_read_int(pb, size) == 1101) {
224  if (!st->codecpar->extradata) {
225  st->codecpar->extradata = av_strdup("BottomUp");
226  if (!st->codecpar->extradata)
227  return AVERROR(ENOMEM);
228  st->codecpar->extradata_size = 9;
229  }
230  }
231  } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
232  var_read_metadata(avctx, name, size);
233  } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {
234  avio_skip(pb, size); // ignore
235  } else
236  return AVERROR_INVALIDDATA;
237 
238  return 0;
239 }
240 
241 static int read_table(AVFormatContext *avctx, AVStream *st,
242  int (*parse)(AVFormatContext *avctx, AVStream *st,
243  const char *name, int size))
244 {
245  unsigned count;
246  int i;
247 
248  AVIOContext *pb = avctx->pb;
249  avio_skip(pb, 4);
250  count = avio_rb32(pb);
251  avio_skip(pb, 4);
252  for (i = 0; i < count; i++) {
253  char name[17];
254  int size;
255 
256  if (avio_feof(pb))
257  return AVERROR_EOF;
258 
259  avio_read(pb, name, 16);
260  name[sizeof(name) - 1] = 0;
261  size = avio_rb32(pb);
262  if (size < 0) {
263  av_log(avctx, AV_LOG_ERROR, "entry size %d is invalid\n", size);
264  return AVERROR_INVALIDDATA;
265  }
266  if (parse(avctx, st, name, size) < 0) {
267  avpriv_request_sample(avctx, "Variable %s", name);
268  avio_skip(pb, size);
269  }
270  }
271  return 0;
272 }
273 
274 static void read_index(AVIOContext *pb, AVStream *st)
275 {
276  uint64_t timestamp = 0;
277  int i;
278  for (i = 0; i < st->nb_frames; i++) {
279  uint32_t pos = avio_rb32(pb);
280  uint32_t size = avio_rb32(pb);
281  avio_skip(pb, 8);
282  if (avio_feof(pb))
283  return ;
284  av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME);
285  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
286  timestamp += size / (st->codecpar->channels * 2LL);
287  } else {
288  timestamp++;
289  }
290  }
291 }
292 
293 static int mv_read_header(AVFormatContext *avctx)
294 {
295  MvContext *mv = avctx->priv_data;
296  AVIOContext *pb = avctx->pb;
297  AVStream *ast = NULL, *vst = NULL; //initialization to suppress warning
298  int version, i;
299  int ret;
300 
301  avio_skip(pb, 4);
302 
303  version = avio_rb16(pb);
304  if (version == 2) {
305  uint64_t timestamp;
306  int v;
307  uint32_t bytes_per_sample;
308  AVRational fps;
309 
310  avio_skip(pb, 10);
311 
312  fps = av_d2q(av_int2double(avio_rb64(pb)), INT_MAX);
313 
314  /* allocate audio track first to prevent unnecessary seeking
315  * (audio packet always precede video packet for a given frame) */
316  v = avio_rb16(pb);
317  if (v == MOVIE_SOUND) {
318  /* movie has sound so allocate an audio stream */
319  ast = avformat_new_stream(avctx, NULL);
320  if (!ast)
321  return AVERROR(ENOMEM);
322  } else if (v != MOVIE_SILENT)
323  return AVERROR_INVALIDDATA;
324 
325  avio_skip(pb, 2);
326 
327  vst = avformat_new_stream(avctx, NULL);
328  if (!vst)
329  return AVERROR(ENOMEM);
330  avpriv_set_pts_info(vst, 64, fps.den, fps.num);
331  vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
332  vst->avg_frame_rate = fps;
333  vst->duration = vst->nb_frames = avio_rb32(pb);
334  v = avio_rb32(pb);
335  switch (v) {
336  case 1:
337  vst->codecpar->codec_id = AV_CODEC_ID_MVC1;
338  break;
339  case 2:
340  vst->codecpar->format = AV_PIX_FMT_ARGB;
341  vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
342  break;
343  default:
344  avpriv_request_sample(avctx, "Video compression %i", v);
345  break;
346  }
347  vst->codecpar->codec_tag = 0;
348  vst->codecpar->width = avio_rb32(pb);
349  vst->codecpar->height = avio_rb32(pb);
350  avio_skip(pb, 12);
351 
352  if (ast) {
354  ast->nb_frames = vst->nb_frames;
355  ast->codecpar->sample_rate = avio_rb32(pb);
356  if (ast->codecpar->sample_rate <= 0) {
357  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate %d\n", ast->codecpar->sample_rate);
358  return AVERROR_INVALIDDATA;
359  }
360  avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
361 
362  bytes_per_sample = avio_rb32(pb);
363 
364  v = avio_rb32(pb);
365  if (v == AUDIO_FORMAT_SIGNED) {
366  switch (bytes_per_sample) {
367  case 1:
369  break;
370  case 2:
372  break;
373  default:
374  avpriv_request_sample(avctx, "Audio sample size %i bytes", bytes_per_sample);
375  break;
376  }
377  } else {
378  avpriv_request_sample(avctx, "Audio compression (format %i)", v);
379  }
380 
381  if (bytes_per_sample == 0)
382  return AVERROR_INVALIDDATA;
383 
384  if (set_channels(avctx, ast, avio_rb32(pb)) < 0)
385  return AVERROR_INVALIDDATA;
386 
387  avio_skip(pb, 8);
388  } else
389  avio_skip(pb, 24); /* skip meaningless audio metadata */
390 
391  var_read_metadata(avctx, "title", 0x80);
392  var_read_metadata(avctx, "comment", 0x100);
393  avio_skip(pb, 0x80);
394 
395  timestamp = 0;
396  for (i = 0; i < vst->nb_frames; i++) {
397  uint32_t pos = avio_rb32(pb);
398  uint32_t asize = avio_rb32(pb);
399  uint32_t vsize = avio_rb32(pb);
400  if (avio_feof(pb))
401  return AVERROR_INVALIDDATA;
402  avio_skip(pb, 8);
403  if (ast) {
404  av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
405  timestamp += asize / (ast->codecpar->channels * (uint64_t)bytes_per_sample);
406  }
407  av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
408  }
409  } else if (!version && avio_rb16(pb) == 3) {
410  avio_skip(pb, 4);
411 
412  if ((ret = read_table(avctx, NULL, parse_global_var)) < 0)
413  return ret;
414 
415  if (mv->nb_audio_tracks < 0 || mv->nb_video_tracks < 0 ||
416  (mv->nb_audio_tracks == 0 && mv->nb_video_tracks == 0)) {
417  av_log(avctx, AV_LOG_ERROR, "Stream count is invalid.\n");
418  return AVERROR_INVALIDDATA;
419  }
420 
421  if (mv->nb_audio_tracks > 1) {
422  avpriv_request_sample(avctx, "Multiple audio streams support");
423  return AVERROR_PATCHWELCOME;
424  } else if (mv->nb_audio_tracks) {
425  ast = avformat_new_stream(avctx, NULL);
426  if (!ast)
427  return AVERROR(ENOMEM);
429  if ((ret = read_table(avctx, ast, parse_audio_var)) < 0)
430  return ret;
431  if (mv->acompression == 100 &&
432  mv->aformat == AUDIO_FORMAT_SIGNED &&
433  ast->codecpar->bits_per_coded_sample == 16) {
435  } else {
436  avpriv_request_sample(avctx,
437  "Audio compression %i (format %i, sr %i)",
438  mv->acompression, mv->aformat,
441  }
442  if (ast->codecpar->channels <= 0) {
443  av_log(avctx, AV_LOG_ERROR, "No valid channel count found.\n");
444  return AVERROR_INVALIDDATA;
445  }
446  }
447 
448  if (mv->nb_video_tracks > 1) {
449  avpriv_request_sample(avctx, "Multiple video streams support");
450  return AVERROR_PATCHWELCOME;
451  } else if (mv->nb_video_tracks) {
452  vst = avformat_new_stream(avctx, NULL);
453  if (!vst)
454  return AVERROR(ENOMEM);
455  vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
456  if ((ret = read_table(avctx, vst, parse_video_var))<0)
457  return ret;
458  }
459 
460  if (mv->nb_audio_tracks)
461  read_index(pb, ast);
462 
463  if (mv->nb_video_tracks)
464  read_index(pb, vst);
465  } else {
466  avpriv_request_sample(avctx, "Version %i", version);
467  return AVERROR_PATCHWELCOME;
468  }
469 
470  return 0;
471 }
472 
474 {
475  MvContext *mv = avctx->priv_data;
476  AVIOContext *pb = avctx->pb;
477  AVStream *st = avctx->streams[mv->stream_index];
478  FFStream *const sti = ffstream(st);
479  const AVIndexEntry *index;
480  int frame = mv->frame[mv->stream_index];
481  int64_t ret;
482  uint64_t pos;
483 
484  if (frame < sti->nb_index_entries) {
485  index = &sti->index_entries[frame];
486  pos = avio_tell(pb);
487  if (index->pos > pos)
488  avio_skip(pb, index->pos - pos);
489  else if (index->pos < pos) {
490  if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
491  return AVERROR(EIO);
492  ret = avio_seek(pb, index->pos, SEEK_SET);
493  if (ret < 0)
494  return ret;
495  }
496  ret = av_get_packet(pb, pkt, index->size);
497  if (ret < 0)
498  return ret;
499 
500  pkt->stream_index = mv->stream_index;
501  pkt->pts = index->timestamp;
503 
504  mv->frame[mv->stream_index]++;
505  mv->eof_count = 0;
506  } else {
507  mv->eof_count++;
508  if (mv->eof_count >= avctx->nb_streams)
509  return AVERROR_EOF;
510 
511  // avoid returning 0 without a packet
512  return AVERROR(EAGAIN);
513  }
514 
515  mv->stream_index++;
516  if (mv->stream_index >= avctx->nb_streams)
517  mv->stream_index = 0;
518 
519  return 0;
520 }
521 
522 static int mv_read_seek(AVFormatContext *avctx, int stream_index,
523  int64_t timestamp, int flags)
524 {
525  MvContext *mv = avctx->priv_data;
526  AVStream *st = avctx->streams[stream_index];
527  int frame, i;
528 
530  return AVERROR(ENOSYS);
531 
532  if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
533  return AVERROR(EIO);
534 
535  frame = av_index_search_timestamp(st, timestamp, flags);
536  if (frame < 0)
537  return AVERROR_INVALIDDATA;
538 
539  for (i = 0; i < avctx->nb_streams; i++)
540  mv->frame[i] = frame;
541  return 0;
542 }
543 
545  .name = "mv",
546  .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics Movie"),
547  .priv_data_size = sizeof(MvContext),
548  .read_probe = mv_probe,
552 };
MvContext::nb_video_tracks
int nb_video_tracks
Definition: mvdec.c:37
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
name
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
Definition: writing_filters.txt:88
MvContext::eof_count
int eof_count
number of streams that have finished
Definition: mvdec.c:40
MvContext::frame
int frame[2]
frame nb for current stream
Definition: mvdec.c:42
AVERROR
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
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:768
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
AVSEEK_FLAG_FRAME
#define AVSEEK_FLAG_FRAME
seeking based on frame number
Definition: avformat.h:2279
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
var_read_string
static char * var_read_string(AVIOContext *pb, int size)
Definition: mvdec.c:62
av_int2double
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
Definition: intfloat.h:60
AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:90
set_channels
static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
Definition: mvdec.c:108
rational.h
mv
static const int8_t mv[256][2]
Definition: 4xm.c:79
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:63
AV_CODEC_ID_MVC2
@ AV_CODEC_ID_MVC2
Definition: codec_id.h:235
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1268
index
fg index
Definition: ffmpeg_filter.c:167
parse
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition: vp3_parser.c:23
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:1015
AVSEEK_FLAG_BYTE
#define AVSEEK_FLAG_BYTE
seeking based on position in bytes
Definition: avformat.h:2277
MOVIE_SILENT
#define MOVIE_SILENT
Definition: mvdec.c:50
intfloat.h
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:428
sample_rate
sample_rate
Definition: ffmpeg_filter.c:153
AVIndexEntry
Definition: avformat.h:801
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:809
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:459
return
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
Definition: filter_design.txt:264
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:431
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:315
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:149
av_add_index_entry
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.
Definition: seek.c:117
AUDIO_FORMAT_SIGNED
#define AUDIO_FORMAT_SIGNED
Definition: mvdec.c:52
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:504
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:985
var_read_int
static int var_read_int(AVIOContext *pb, int size)
Definition: mvdec.c:79
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:91
AV_DICT_DONT_STRDUP_VAL
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition: dict.h:72
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:318
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:790
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVFormatContext::metadata
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1429
AVInputFormat
Definition: avformat.h:650
MvContext::aformat
int aformat
audio format
Definition: mvdec.c:45
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:655
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:449
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
channels
channels
Definition: aptx.h:33
AVFormatContext
Format I/O context.
Definition: avformat.h:1200
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1095
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
parse_audio_var
static int parse_audio_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse audio variable.
Definition: mvdec.c:148
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
var_read_metadata
static void var_read_metadata(AVFormatContext *avctx, const char *tag, int size)
Definition: mvdec.c:101
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
mv_read_packet
static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: mvdec.c:473
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:937
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition: avformat.h:1242
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:447
parse_video_var
static int parse_video_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse video variable.
Definition: mvdec.c:184
parse_global_var
static int parse_global_var(AVFormatContext *avctx, AVStream *st, const char *name, int size)
Parse global variable.
Definition: mvdec.c:124
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
MvContext::stream_index
int stream_index
current stream index
Definition: mvdec.c:41
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:987
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1256
MOVIE_SOUND
#define MOVIE_SOUND
Definition: mvdec.c:49
eval.h
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVIOContext::seekable
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:262
FFStream
Definition: internal.h:193
avio_get_str
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition: aviobuf.c:895
size
int size
Definition: twinvq_data.h:10344
ff_mv_demuxer
const AVInputFormat ff_mv_demuxer
Definition: mvdec.c:544
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
AV_RB32
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
Definition: bytestream.h:96
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:1004
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
mv_probe
static int mv_probe(const AVProbeData *p)
Definition: mvdec.c:54
version
version
Definition: libkvazaar.c:313
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:57
mv_read_seek
static int mv_read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
Definition: mvdec.c:522
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
AVCodecParameters::height
int height
Definition: codec_par.h:127
value
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
Definition: writing_filters.txt:86
av_d2q
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition: rational.c:106
MvContext
Definition: mvdec.c:36
AV_CODEC_ID_MVC1
@ AV_CODEC_ID_MVC1
Definition: codec_id.h:234
av_get_packet
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:197
read_index
static void read_index(AVIOContext *pb, AVStream *st)
Definition: mvdec.c:274
tag
uint32_t tag
Definition: movenc.c:1596
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:935
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:260
frame
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
Definition: filter_design.txt:264
av_strtod
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition: eval.c:106
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
Definition: aviobuf.c:775
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
mv_read_header
static int mv_read_header(AVFormatContext *avctx)
Definition: mvdec.c:293
channel_layout.h
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
AVRational::den
int den
Denominator.
Definition: rational.h:60
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:641
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:1195
AVPacket::stream_index
int stream_index
Definition: packet.h:375
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:347
FFStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:276
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:279
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
MvContext::nb_audio_tracks
int nb_audio_tracks
Definition: mvdec.c:38
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
AVCodecParameters::format
int format
Definition: codec_par.h:84
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
MvContext::acompression
int acompression
compression level for audio stream
Definition: mvdec.c:44
AV_CODEC_ID_SGIRLE
@ AV_CODEC_ID_SGIRLE
Definition: codec_id.h:233
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
AVCodecParameters::channel_layout
uint64_t channel_layout
Audio only.
Definition: codec_par.h:162
read_table
static int read_table(AVFormatContext *avctx, AVStream *st, int(*parse)(AVFormatContext *avctx, AVStream *st, const char *name, int size))
Definition: mvdec.c:241
convert_header.str
string str
Definition: convert_header.py:20
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
var_read_float
static AVRational var_read_float(AVIOContext *pb, int size)
Definition: mvdec.c:90
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1228
AV_RB16
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
Definition: bytestream.h:98
av_index_search_timestamp
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: seek.c:237
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:375