FFmpeg
mlvdec.c
Go to the documentation of this file.
1 /*
2  * Magic Lantern Video (MLV) demuxer
3  * Copyright (c) 2014 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  * Magic Lantern Video (MLV) demuxer
25  */
26 
27 #include "libavutil/eval.h"
28 #include "libavutil/imgutils.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/rational.h"
31 #include "avformat.h"
32 #include "avio_internal.h"
33 #include "internal.h"
34 #include "riff.h"
35 
36 #define MLV_VERSION "v2.0"
37 
38 #define MLV_VIDEO_CLASS_RAW 1
39 #define MLV_VIDEO_CLASS_YUV 2
40 #define MLV_VIDEO_CLASS_JPEG 3
41 #define MLV_VIDEO_CLASS_H264 4
42 
43 #define MLV_AUDIO_CLASS_WAV 1
44 
45 #define MLV_CLASS_FLAG_DELTA 0x40
46 #define MLV_CLASS_FLAG_LZMA 0x80
47 
48 typedef struct {
49  AVIOContext *pb[101];
50  int class[2];
52  uint64_t pts;
53 } MlvContext;
54 
55 static int probe(const AVProbeData *p)
56 {
57  if (AV_RL32(p->buf) == MKTAG('M','L','V','I') &&
58  AV_RL32(p->buf + 4) >= 52 &&
59  !memcmp(p->buf + 8, MLV_VERSION, 5))
60  return AVPROBE_SCORE_MAX;
61  return 0;
62 }
63 
64 static int check_file_header(AVIOContext *pb, uint64_t guid)
65 {
66  unsigned int size;
67  uint8_t version[8];
68 
69  avio_skip(pb, 4);
70  size = avio_rl32(pb);
71  if (size < 52)
72  return AVERROR_INVALIDDATA;
73  avio_read(pb, version, 8);
74  if (memcmp(version, MLV_VERSION, 5) || avio_rl64(pb) != guid)
75  return AVERROR_INVALIDDATA;
76  avio_skip(pb, size - 24);
77  return 0;
78 }
79 
80 static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, unsigned size)
81 {
82  char * value = av_malloc(size + 1);
83  if (!value) {
84  avio_skip(pb, size);
85  return;
86  }
87 
88  avio_read(pb, value, size);
89  if (!value[0]) {
90  av_free(value);
91  return;
92  }
93 
94  value[size] = 0;
96 }
97 
98 static void read_uint8(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
99 {
100  av_dict_set_int(&avctx->metadata, tag, avio_r8(pb), 0);
101 }
102 
103 static void read_uint16(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
104 {
105  av_dict_set_int(&avctx->metadata, tag, avio_rl16(pb), 0);
106 }
107 
108 static void read_uint32(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
109 {
110  av_dict_set_int(&avctx->metadata, tag, avio_rl32(pb), 0);
111 }
112 
113 static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
114 {
115  av_dict_set_int(&avctx->metadata, tag, avio_rl64(pb), 0);
116 }
117 
118 static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
119 {
120  FFStream *const vsti = ffstream(vst), *const asti = ffstream(ast);
121  MlvContext *mlv = avctx->priv_data;
122  AVIOContext *pb = mlv->pb[file];
123  int ret;
124  while (!avio_feof(pb)) {
125  int type;
126  unsigned int size;
127  type = avio_rl32(pb);
128  size = avio_rl32(pb);
129  avio_skip(pb, 8); //timestamp
130  if (size < 16)
131  break;
132  size -= 16;
133  if (vst && type == MKTAG('R','A','W','I') && size >= 164) {
134  unsigned width = avio_rl16(pb);
135  unsigned height = avio_rl16(pb);
136  unsigned bits_per_coded_sample;
137  ret = av_image_check_size(width, height, 0, avctx);
138  if (ret < 0)
139  return ret;
140  if (avio_rl32(pb) != 1)
141  avpriv_request_sample(avctx, "raw api version");
142  avio_skip(pb, 20); // pointer, width, height, pitch, frame_size
143  bits_per_coded_sample = avio_rl32(pb);
144  if (bits_per_coded_sample > (INT_MAX - 7) / (width * height)) {
145  av_log(avctx, AV_LOG_ERROR,
146  "invalid bits_per_coded_sample %u (size: %ux%u)\n",
147  bits_per_coded_sample, width, height);
148  return AVERROR_INVALIDDATA;
149  }
150  vst->codecpar->width = width;
151  vst->codecpar->height = height;
152  vst->codecpar->bits_per_coded_sample = bits_per_coded_sample;
153  avio_skip(pb, 8 + 16 + 24); // black_level, white_level, xywh, active_area, exposure_bias
154  if (avio_rl32(pb) != 0x2010100) /* RGGB */
155  avpriv_request_sample(avctx, "cfa_pattern");
156  avio_skip(pb, 80); // calibration_illuminant1, color_matrix1, dynamic_range
158  vst->codecpar->codec_tag = MKTAG('B', 'I', 'T', 16);
159  size -= 164;
160  } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) {
161  ret = ff_get_wav_header(avctx, pb, ast->codecpar, 16, 0);
162  if (ret < 0)
163  return ret;
164  size -= 16;
165  } else if (type == MKTAG('I','N','F','O')) {
166  if (size > 0)
167  read_string(avctx, pb, "info", size);
168  continue;
169  } else if (type == MKTAG('I','D','N','T') && size >= 36) {
170  read_string(avctx, pb, "cameraName", 32);
171  read_uint32(avctx, pb, "cameraModel", "0x%"PRIx32);
172  size -= 36;
173  if (size >= 32) {
174  read_string(avctx, pb, "cameraSerial", 32);
175  size -= 32;
176  }
177  } else if (type == MKTAG('L','E','N','S') && size >= 48) {
178  read_uint16(avctx, pb, "focalLength", "%i");
179  read_uint16(avctx, pb, "focalDist", "%i");
180  read_uint16(avctx, pb, "aperture", "%i");
181  read_uint8(avctx, pb, "stabilizerMode", "%i");
182  read_uint8(avctx, pb, "autofocusMode", "%i");
183  read_uint32(avctx, pb, "flags", "0x%"PRIx32);
184  read_uint32(avctx, pb, "lensID", "%"PRIi32);
185  read_string(avctx, pb, "lensName", 32);
186  size -= 48;
187  if (size >= 32) {
188  read_string(avctx, pb, "lensSerial", 32);
189  size -= 32;
190  }
191  } else if (vst && type == MKTAG('V', 'I', 'D', 'F') && size >= 4) {
192  uint64_t pts = avio_rl32(pb);
195  avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
196  size -= 4;
197  } else if (ast && type == MKTAG('A', 'U', 'D', 'F') && size >= 4) {
198  uint64_t pts = avio_rl32(pb);
199  ff_add_index_entry(&asti->index_entries, &asti->nb_index_entries,
200  &asti->index_entries_allocated_size,
201  avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
202  size -= 4;
203  } else if (vst && type == MKTAG('W','B','A','L') && size >= 28) {
204  read_uint32(avctx, pb, "wb_mode", "%"PRIi32);
205  read_uint32(avctx, pb, "kelvin", "%"PRIi32);
206  read_uint32(avctx, pb, "wbgain_r", "%"PRIi32);
207  read_uint32(avctx, pb, "wbgain_g", "%"PRIi32);
208  read_uint32(avctx, pb, "wbgain_b", "%"PRIi32);
209  read_uint32(avctx, pb, "wbs_gm", "%"PRIi32);
210  read_uint32(avctx, pb, "wbs_ba", "%"PRIi32);
211  size -= 28;
212  } else if (type == MKTAG('R','T','C','I') && size >= 20) {
213  char str[32];
214  struct tm time = { 0 };
215  time.tm_sec = avio_rl16(pb);
216  time.tm_min = avio_rl16(pb);
217  time.tm_hour = avio_rl16(pb);
218  time.tm_mday = avio_rl16(pb);
219  time.tm_mon = avio_rl16(pb);
220  time.tm_year = avio_rl16(pb);
221  time.tm_wday = avio_rl16(pb);
222  time.tm_yday = avio_rl16(pb);
223  time.tm_isdst = avio_rl16(pb);
224  avio_skip(pb, 2);
225  if (strftime(str, sizeof(str), "%Y-%m-%d %H:%M:%S", &time))
226  av_dict_set(&avctx->metadata, "time", str, 0);
227  size -= 20;
228  } else if (type == MKTAG('E','X','P','O') && size >= 16) {
229  av_dict_set(&avctx->metadata, "isoMode", avio_rl32(pb) ? "auto" : "manual", 0);
230  read_uint32(avctx, pb, "isoValue", "%"PRIi32);
231  read_uint32(avctx, pb, "isoAnalog", "%"PRIi32);
232  read_uint32(avctx, pb, "digitalGain", "%"PRIi32);
233  size -= 16;
234  if (size >= 8) {
235  read_uint64(avctx, pb, "shutterValue", "%"PRIi64);
236  size -= 8;
237  }
238  } else if (type == MKTAG('S','T','Y','L') && size >= 36) {
239  read_uint32(avctx, pb, "picStyleId", "%"PRIi32);
240  read_uint32(avctx, pb, "contrast", "%"PRIi32);
241  read_uint32(avctx, pb, "sharpness", "%"PRIi32);
242  read_uint32(avctx, pb, "saturation", "%"PRIi32);
243  read_uint32(avctx, pb, "colortone", "%"PRIi32);
244  read_string(avctx, pb, "picStyleName", 16);
245  size -= 36;
246  } else if (type == MKTAG('M','A','R','K')) {
247  } else if (type == MKTAG('N','U','L','L')) {
248  } else if (type == MKTAG('M','L','V','I')) { /* occurs when MLV and Mnn files are concatenated */
249  } else {
250  av_log(avctx, AV_LOG_INFO, "unsupported tag %s, size %u\n",
252  }
253  avio_skip(pb, size);
254  }
255  return 0;
256 }
257 
258 static int read_header(AVFormatContext *avctx)
259 {
260  MlvContext *mlv = avctx->priv_data;
261  AVIOContext *pb = avctx->pb;
262  AVStream *vst = NULL, *ast = NULL;
263  FFStream *vsti = NULL, *asti = NULL;
264  int size, ret;
265  unsigned nb_video_frames, nb_audio_frames;
266  uint64_t guid;
267  char guidstr[32];
268 
269  avio_skip(pb, 4);
270  size = avio_rl32(pb);
271  if (size < 52)
272  return AVERROR_INVALIDDATA;
273 
274  avio_skip(pb, 8);
275 
276  guid = avio_rl64(pb);
277  snprintf(guidstr, sizeof(guidstr), "0x%"PRIx64, guid);
278  av_dict_set(&avctx->metadata, "guid", guidstr, 0);
279 
280  avio_skip(pb, 8); //fileNum, fileCount, fileFlags
281 
282  mlv->class[0] = avio_rl16(pb);
283  mlv->class[1] = avio_rl16(pb);
284 
285  nb_video_frames = avio_rl32(pb);
286  nb_audio_frames = avio_rl32(pb);
287 
288  if (nb_video_frames && mlv->class[0]) {
289  vst = avformat_new_stream(avctx, NULL);
290  if (!vst)
291  return AVERROR(ENOMEM);
292  vsti = ffstream(vst);
293 
294  vst->id = 0;
295  vst->nb_frames = nb_video_frames;
297  avpriv_request_sample(avctx, "compression");
299  switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)) {
300  case MLV_VIDEO_CLASS_RAW:
302  break;
303  case MLV_VIDEO_CLASS_YUV:
306  vst->codecpar->codec_tag = 0;
307  break;
310  vst->codecpar->codec_tag = 0;
311  break;
314  vst->codecpar->codec_tag = 0;
315  break;
316  default:
317  avpriv_request_sample(avctx, "unknown video class");
318  }
319  }
320 
321  if (nb_audio_frames && mlv->class[1]) {
322  ast = avformat_new_stream(avctx, NULL);
323  if (!ast)
324  return AVERROR(ENOMEM);
325  asti = ffstream(ast);
326  ast->id = 1;
327  ast->nb_frames = nb_audio_frames;
328  if ((mlv->class[1] & MLV_CLASS_FLAG_LZMA))
329  avpriv_request_sample(avctx, "compression");
330  if ((mlv->class[1] & ~MLV_CLASS_FLAG_LZMA) != MLV_AUDIO_CLASS_WAV)
331  avpriv_request_sample(avctx, "unknown audio class");
332 
333  ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
334  avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
335  }
336 
337  if (vst) {
339  framerate.num = avio_rl32(pb);
340  framerate.den = avio_rl32(pb);
341  avpriv_set_pts_info(vst, 64, framerate.den, framerate.num);
342  } else
343  avio_skip(pb, 8);
344 
345  avio_skip(pb, size - 52);
346 
347  /* scan primary file */
348  mlv->pb[100] = avctx->pb;
349  ret = scan_file(avctx, vst, ast, 100);
350  if (ret < 0)
351  return ret;
352 
353  /* scan secondary files */
354  if (strlen(avctx->url) > 2) {
355  int i;
356  char *filename = av_strdup(avctx->url);
357 
358  if (!filename)
359  return AVERROR(ENOMEM);
360 
361  for (i = 0; i < 100; i++) {
362  snprintf(filename + strlen(filename) - 2, 3, "%02d", i);
363  if (avctx->io_open(avctx, &mlv->pb[i], filename, AVIO_FLAG_READ, NULL) < 0)
364  break;
365  if (check_file_header(mlv->pb[i], guid) < 0) {
366  av_log(avctx, AV_LOG_WARNING, "ignoring %s; bad format or guid mismatch\n", filename);
367  ff_format_io_close(avctx, &mlv->pb[i]);
368  continue;
369  }
370  av_log(avctx, AV_LOG_INFO, "scanning %s\n", filename);
371  ret = scan_file(avctx, vst, ast, i);
372  if (ret < 0) {
373  av_log(avctx, AV_LOG_WARNING, "ignoring %s; %s\n", filename, av_err2str(ret));
374  ff_format_io_close(avctx, &mlv->pb[i]);
375  continue;
376  }
377  }
378  av_free(filename);
379  }
380 
381  if (vst)
382  vst->duration = vsti->nb_index_entries;
383  if (ast)
384  ast->duration = asti->nb_index_entries;
385 
386  if ((vst && !vsti->nb_index_entries) || (ast && !asti->nb_index_entries)) {
387  av_log(avctx, AV_LOG_ERROR, "no index entries found\n");
388  return AVERROR_INVALIDDATA;
389  }
390 
391  if (vst && ast)
392  avio_seek(pb, FFMIN(vsti->index_entries[0].pos, asti->index_entries[0].pos), SEEK_SET);
393  else if (vst)
394  avio_seek(pb, vsti->index_entries[0].pos, SEEK_SET);
395  else if (ast)
396  avio_seek(pb, asti->index_entries[0].pos, SEEK_SET);
397 
398  return 0;
399 }
400 
402 {
403  MlvContext *mlv = avctx->priv_data;
404  AVIOContext *pb;
405  AVStream *st;
406  FFStream *sti;
407  int index, ret;
408  unsigned int size, space;
409 
410  if (!avctx->nb_streams)
411  return AVERROR_EOF;
412 
413  st = avctx->streams[mlv->stream_index];
414  sti = ffstream(st);
415  if (mlv->pts >= st->duration)
416  return AVERROR_EOF;
417 
419  if (index < 0) {
420  av_log(avctx, AV_LOG_ERROR, "could not find index entry for frame %"PRId64"\n", mlv->pts);
421  return AVERROR(EIO);
422  }
423 
424  pb = mlv->pb[sti->index_entries[index].size];
425  if (!pb) {
426  ret = FFERROR_REDO;
427  goto next_packet;
428  }
429  avio_seek(pb, sti->index_entries[index].pos, SEEK_SET);
430 
431  avio_skip(pb, 4); // blockType
432  size = avio_rl32(pb);
433  if (size < 16)
434  return AVERROR_INVALIDDATA;
435  avio_skip(pb, 12); //timestamp, frameNumber
437  avio_skip(pb, 8); // cropPosX, cropPosY, panPosX, panPosY
438  space = avio_rl32(pb);
439  avio_skip(pb, space);
440 
441  if ((mlv->class[st->id] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA))) {
443  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
444  ret = av_get_packet(pb, pkt, (st->codecpar->width * st->codecpar->height * st->codecpar->bits_per_coded_sample + 7) >> 3);
445  } else { // AVMEDIA_TYPE_AUDIO
446  if (space > UINT_MAX - 24 || size < (24 + space))
447  return AVERROR_INVALIDDATA;
448  ret = av_get_packet(pb, pkt, size - (24 + space));
449  }
450 
451  if (ret < 0)
452  return ret;
453 
454  pkt->stream_index = mlv->stream_index;
455  pkt->pts = mlv->pts;
456 
457  ret = 0;
458 next_packet:
459  mlv->stream_index++;
460  if (mlv->stream_index == avctx->nb_streams) {
461  mlv->stream_index = 0;
462  mlv->pts++;
463  }
464  return ret;
465 }
466 
467 static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
468 {
469  MlvContext *mlv = avctx->priv_data;
470 
472  return AVERROR(ENOSYS);
473 
474  if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
475  return AVERROR(EIO);
476 
477  mlv->pts = timestamp;
478  return 0;
479 }
480 
482 {
483  MlvContext *mlv = s->priv_data;
484  int i;
485  for (i = 0; i < 100; i++)
486  ff_format_io_close(s, &mlv->pb[i]);
487  return 0;
488 }
489 
491  .name = "mlv",
492  .long_name = NULL_IF_CONFIG_SMALL("Magic Lantern Video (MLV)"),
493  .priv_data_size = sizeof(MlvContext),
494  .flags_internal = FF_FMT_INIT_CLEANUP,
495  .read_probe = probe,
499  .read_seek = read_seek,
500 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
FF_FMT_INIT_CLEANUP
#define FF_FMT_INIT_CLEANUP
For an AVInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: internal.h:48
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:724
MLV_VIDEO_CLASS_RAW
#define MLV_VIDEO_CLASS_RAW
Definition: mlvdec.c:38
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
space
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated space
Definition: undefined.txt:4
MLV_AUDIO_CLASS_WAV
#define MLV_AUDIO_CLASS_WAV
Definition: mlvdec.c:43
FFERROR_REDO
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
Definition: internal.h:886
AVSEEK_FLAG_FRAME
#define AVSEEK_FLAG_FRAME
seeking based on frame number
Definition: avformat.h:2154
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
rational.h
ff_mlv_demuxer
const AVInputFormat ff_mlv_demuxer
Definition: mlvdec.c:490
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:63
MlvContext::stream_index
int stream_index
Definition: mlvdec.c:51
read_uint64
static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:113
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1165
index
fg index
Definition: ffmpeg_filter.c:168
ff_add_index_entry
int ff_add_index_entry(AVIndexEntry **index_entries, int *nb_index_entries, unsigned int *index_entries_allocated_size, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Internal version of av_add_index_entry.
Definition: seek.c:59
read_string
static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, unsigned size)
Definition: mlvdec.c:80
AVSEEK_FLAG_BYTE
#define AVSEEK_FLAG_BYTE
seeking based on position in bytes
Definition: avformat.h:2152
read_uint32
static void read_uint32(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:108
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
scan_file
static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
Definition: mlvdec.c:118
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:785
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
framerate
int framerate
Definition: h264_levels.c:65
MlvContext
Definition: mlvdec.c:48
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:426
AVSEEK_FLAG_ANY
#define AVSEEK_FLAG_ANY
seek to any frame, even non-keyframes
Definition: avformat.h:2153
FFStream::index_entries_allocated_size
unsigned int index_entries_allocated_size
Definition: internal.h:274
AVIOContext::pos
int64_t pos
position in the file of the current buffer
Definition: avio.h:238
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:486
type
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 type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:653
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:888
read_header
static int read_header(AVFormatContext *avctx)
Definition: mlvdec.c:258
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:726
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
read_seek
static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
Definition: mlvdec.c:467
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:1326
AVInputFormat
Definition: avformat.h:626
read_uint16
static void read_uint16(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:103
MLV_VERSION
#define MLV_VERSION
Definition: mlvdec.c:36
width
#define width
read_uint8
static void read_uint8(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:98
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
MlvContext::pb
AVIOContext * pb[101]
Definition: mlvdec.c:49
AV_PIX_FMT_BAYER_RGGB16LE
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:256
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:631
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
AVIndexEntry::size
int size
Definition: avformat.h:788
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
AVFormatContext
Format I/O context.
Definition: avformat.h:1097
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:992
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
read_close
static int read_close(AVFormatContext *s)
Definition: mlvdec.c:481
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
MLV_VIDEO_CLASS_JPEG
#define MLV_VIDEO_CLASS_JPEG
Definition: mlvdec.c:40
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFormatContext::pb
AVIOContext * pb
I/O context.
Definition: avformat.h:1139
read_packet
static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: mlvdec.c:401
FFStream::nb_index_entries
int nb_index_entries
Definition: internal.h:273
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
AVStream::nb_frames
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:890
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1153
eval.h
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:742
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:188
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:121
AVFormatContext::url
char * url
input or output URL.
Definition: avformat.h:1180
size
int size
Definition: twinvq_data.h:10344
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:616
height
#define height
MLV_VIDEO_CLASS_YUV
#define MLV_VIDEO_CLASS_YUV
Definition: mlvdec.c:39
version
version
Definition: libkvazaar.c:307
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:57
check_file_header
static int check_file_header(AVIOContext *pb, uint64_t guid)
Definition: mlvdec.c:64
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
avio_internal.h
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
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_get_wav_header
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
Definition: riffdec.c:90
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:196
MLV_VIDEO_CLASS_H264
#define MLV_VIDEO_CLASS_H264
Definition: mlvdec.c:41
tag
uint32_t tag
Definition: movenc.c:1595
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:852
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:845
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
avformat.h
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
AVFormatContext::io_open
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
Definition: avformat.h:1656
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:778
MLV_CLASS_FLAG_DELTA
#define MLV_CLASS_FLAG_DELTA
Definition: mlvdec.c:45
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:1146
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:333
FFStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:271
av_dict_set_int
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
Definition: dict.c:147
ff_format_io_close
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition: utils.c:1798
AVIO_FLAG_READ
#define AVIO_FLAG_READ
read-only
Definition: avio.h:603
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
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
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
riff.h
avio_rl64
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:750
convert_header.str
string str
Definition: convert_header.py:20
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
MLV_CLASS_FLAG_LZMA
#define MLV_CLASS_FLAG_LZMA
Definition: mlvdec.c:46
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
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
probe
static int probe(const AVProbeData *p)
Definition: mlvdec.c:55
av_image_check_size
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:318
snprintf
#define snprintf
Definition: snprintf.h:34
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1125
MlvContext::class
int class[2]
Definition: mlvdec.c:50
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
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
MlvContext::pts
uint64_t pts
Definition: mlvdec.c:52
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:360