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