FFmpeg  4.3.8
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 read_close(AVFormatContext *s);
56 
57 static int probe(const AVProbeData *p)
58 {
59  if (AV_RL32(p->buf) == MKTAG('M','L','V','I') &&
60  AV_RL32(p->buf + 4) >= 52 &&
61  !memcmp(p->buf + 8, MLV_VERSION, 5))
62  return AVPROBE_SCORE_MAX;
63  return 0;
64 }
65 
66 static int check_file_header(AVIOContext *pb, uint64_t guid)
67 {
68  unsigned int size;
69  uint8_t version[8];
70 
71  avio_skip(pb, 4);
72  size = avio_rl32(pb);
73  if (size < 52)
74  return AVERROR_INVALIDDATA;
75  avio_read(pb, version, 8);
76  if (memcmp(version, MLV_VERSION, 5) || avio_rl64(pb) != guid)
77  return AVERROR_INVALIDDATA;
78  avio_skip(pb, size - 24);
79  return 0;
80 }
81 
82 static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, unsigned size)
83 {
84  char * value = av_malloc(size + 1);
85  if (!value) {
86  avio_skip(pb, size);
87  return;
88  }
89 
90  avio_read(pb, value, size);
91  if (!value[0]) {
92  av_free(value);
93  return;
94  }
95 
96  value[size] = 0;
97  av_dict_set(&avctx->metadata, tag, value, AV_DICT_DONT_STRDUP_VAL);
98 }
99 
100 static void read_uint8(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
101 {
102  av_dict_set_int(&avctx->metadata, tag, avio_r8(pb), 0);
103 }
104 
105 static void read_uint16(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
106 {
107  av_dict_set_int(&avctx->metadata, tag, avio_rl16(pb), 0);
108 }
109 
110 static void read_uint32(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
111 {
112  av_dict_set_int(&avctx->metadata, tag, avio_rl32(pb), 0);
113 }
114 
115 static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
116 {
117  av_dict_set_int(&avctx->metadata, tag, avio_rl64(pb), 0);
118 }
119 
120 static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
121 {
122  MlvContext *mlv = avctx->priv_data;
123  AVIOContext *pb = mlv->pb[file];
124  int ret;
125  while (!avio_feof(pb)) {
126  int type;
127  unsigned int size;
128  type = avio_rl32(pb);
129  size = avio_rl32(pb);
130  avio_skip(pb, 8); //timestamp
131  if (size < 16)
132  break;
133  size -= 16;
134  if (vst && type == MKTAG('R','A','W','I') && size >= 164) {
135  unsigned width = avio_rl16(pb);
136  unsigned height = avio_rl16(pb);
137  unsigned bits_per_coded_sample;
138  ret = av_image_check_size(width, height, 0, avctx);
139  if (ret < 0)
140  return ret;
141  if (avio_rl32(pb) != 1)
142  avpriv_request_sample(avctx, "raw api version");
143  avio_skip(pb, 20); // pointer, width, height, pitch, frame_size
144  bits_per_coded_sample = avio_rl32(pb);
145  if (bits_per_coded_sample > (INT_MAX - 7) / (width * height)) {
146  av_log(avctx, AV_LOG_ERROR,
147  "invalid bits_per_coded_sample %u (size: %ux%u)\n",
148  bits_per_coded_sample, width, height);
149  return AVERROR_INVALIDDATA;
150  }
151  vst->codecpar->width = width;
152  vst->codecpar->height = height;
153  vst->codecpar->bits_per_coded_sample = bits_per_coded_sample;
154  avio_skip(pb, 8 + 16 + 24); // black_level, white_level, xywh, active_area, exposure_bias
155  if (avio_rl32(pb) != 0x2010100) /* RGGB */
156  avpriv_request_sample(avctx, "cfa_pattern");
157  avio_skip(pb, 80); // calibration_illuminant1, color_matrix1, dynamic_range
159  vst->codecpar->codec_tag = MKTAG('B', 'I', 'T', 16);
160  size -= 164;
161  } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) {
162  ret = ff_get_wav_header(avctx, pb, ast->codecpar, 16, 0);
163  if (ret < 0)
164  return ret;
165  size -= 16;
166  } else if (type == MKTAG('I','N','F','O')) {
167  if (size > 0)
168  read_string(avctx, pb, "info", size);
169  continue;
170  } else if (type == MKTAG('I','D','N','T') && size >= 36) {
171  read_string(avctx, pb, "cameraName", 32);
172  read_uint32(avctx, pb, "cameraModel", "0x%"PRIx32);
173  size -= 36;
174  if (size >= 32) {
175  read_string(avctx, pb, "cameraSerial", 32);
176  size -= 32;
177  }
178  } else if (type == MKTAG('L','E','N','S') && size >= 48) {
179  read_uint16(avctx, pb, "focalLength", "%i");
180  read_uint16(avctx, pb, "focalDist", "%i");
181  read_uint16(avctx, pb, "aperture", "%i");
182  read_uint8(avctx, pb, "stabilizerMode", "%i");
183  read_uint8(avctx, pb, "autofocusMode", "%i");
184  read_uint32(avctx, pb, "flags", "0x%"PRIx32);
185  read_uint32(avctx, pb, "lensID", "%"PRIi32);
186  read_string(avctx, pb, "lensName", 32);
187  size -= 48;
188  if (size >= 32) {
189  read_string(avctx, pb, "lensSerial", 32);
190  size -= 32;
191  }
192  } else if (vst && type == MKTAG('V', 'I', 'D', 'F') && size >= 4) {
193  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);
200  avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
201  size -= 4;
202  } else if (vst && type == MKTAG('W','B','A','L') && size >= 28) {
203  read_uint32(avctx, pb, "wb_mode", "%"PRIi32);
204  read_uint32(avctx, pb, "kelvin", "%"PRIi32);
205  read_uint32(avctx, pb, "wbgain_r", "%"PRIi32);
206  read_uint32(avctx, pb, "wbgain_g", "%"PRIi32);
207  read_uint32(avctx, pb, "wbgain_b", "%"PRIi32);
208  read_uint32(avctx, pb, "wbs_gm", "%"PRIi32);
209  read_uint32(avctx, pb, "wbs_ba", "%"PRIi32);
210  size -= 28;
211  } else if (type == MKTAG('R','T','C','I') && size >= 20) {
212  char str[32];
213  struct tm time = { 0 };
214  time.tm_sec = avio_rl16(pb);
215  time.tm_min = avio_rl16(pb);
216  time.tm_hour = avio_rl16(pb);
217  time.tm_mday = avio_rl16(pb);
218  time.tm_mon = avio_rl16(pb);
219  time.tm_year = avio_rl16(pb);
220  time.tm_wday = avio_rl16(pb);
221  time.tm_yday = avio_rl16(pb);
222  time.tm_isdst = avio_rl16(pb);
223  avio_skip(pb, 2);
224  if (strftime(str, sizeof(str), "%Y-%m-%d %H:%M:%S", &time))
225  av_dict_set(&avctx->metadata, "time", str, 0);
226  size -= 20;
227  } else if (type == MKTAG('E','X','P','O') && size >= 16) {
228  av_dict_set(&avctx->metadata, "isoMode", avio_rl32(pb) ? "auto" : "manual", 0);
229  read_uint32(avctx, pb, "isoValue", "%"PRIi32);
230  read_uint32(avctx, pb, "isoAnalog", "%"PRIi32);
231  read_uint32(avctx, pb, "digitalGain", "%"PRIi32);
232  size -= 16;
233  if (size >= 8) {
234  read_uint64(avctx, pb, "shutterValue", "%"PRIi64);
235  size -= 8;
236  }
237  } else if (type == MKTAG('S','T','Y','L') && size >= 36) {
238  read_uint32(avctx, pb, "picStyleId", "%"PRIi32);
239  read_uint32(avctx, pb, "contrast", "%"PRIi32);
240  read_uint32(avctx, pb, "sharpness", "%"PRIi32);
241  read_uint32(avctx, pb, "saturation", "%"PRIi32);
242  read_uint32(avctx, pb, "colortone", "%"PRIi32);
243  read_string(avctx, pb, "picStyleName", 16);
244  size -= 36;
245  } else if (type == MKTAG('M','A','R','K')) {
246  } else if (type == MKTAG('N','U','L','L')) {
247  } else if (type == MKTAG('M','L','V','I')) { /* occurs when MLV and Mnn files are concatenated */
248  } else {
249  av_log(avctx, AV_LOG_INFO, "unsupported tag %s, size %u\n",
250  av_fourcc2str(type), size);
251  }
252  avio_skip(pb, size);
253  }
254  return 0;
255 }
256 
257 static int read_header(AVFormatContext *avctx)
258 {
259  MlvContext *mlv = avctx->priv_data;
260  AVIOContext *pb = avctx->pb;
261  AVStream *vst = NULL, *ast = NULL;
262  int size, ret;
263  unsigned nb_video_frames, nb_audio_frames;
264  uint64_t guid;
265  char guidstr[32];
266 
267  avio_skip(pb, 4);
268  size = avio_rl32(pb);
269  if (size < 52)
270  return AVERROR_INVALIDDATA;
271 
272  avio_skip(pb, 8);
273 
274  guid = avio_rl64(pb);
275  snprintf(guidstr, sizeof(guidstr), "0x%"PRIx64, guid);
276  av_dict_set(&avctx->metadata, "guid", guidstr, 0);
277 
278  avio_skip(pb, 8); //fileNum, fileCount, fileFlags
279 
280  mlv->class[0] = avio_rl16(pb);
281  mlv->class[1] = avio_rl16(pb);
282 
283  nb_video_frames = avio_rl32(pb);
284  nb_audio_frames = avio_rl32(pb);
285 
286  if (nb_video_frames && mlv->class[0]) {
287  vst = avformat_new_stream(avctx, NULL);
288  if (!vst)
289  return AVERROR(ENOMEM);
290  vst->id = 0;
291  vst->nb_frames = nb_video_frames;
293  avpriv_request_sample(avctx, "compression");
295  switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)) {
296  case MLV_VIDEO_CLASS_RAW:
298  break;
299  case MLV_VIDEO_CLASS_YUV:
302  vst->codecpar->codec_tag = 0;
303  break;
306  vst->codecpar->codec_tag = 0;
307  break;
310  vst->codecpar->codec_tag = 0;
311  break;
312  default:
313  avpriv_request_sample(avctx, "unknown video class");
314  }
315  }
316 
317  if (nb_audio_frames && mlv->class[1]) {
318  ast = avformat_new_stream(avctx, NULL);
319  if (!ast)
320  return AVERROR(ENOMEM);
321  ast->id = 1;
322  ast->nb_frames = nb_audio_frames;
323  if ((mlv->class[1] & MLV_CLASS_FLAG_LZMA))
324  avpriv_request_sample(avctx, "compression");
325  if ((mlv->class[1] & ~MLV_CLASS_FLAG_LZMA) != MLV_AUDIO_CLASS_WAV)
326  avpriv_request_sample(avctx, "unknown audio class");
327 
328  ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
329  avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
330  }
331 
332  if (vst) {
334  framerate.num = avio_rl32(pb);
335  framerate.den = avio_rl32(pb);
336  avpriv_set_pts_info(vst, 64, framerate.den, framerate.num);
337  } else
338  avio_skip(pb, 8);
339 
340  avio_skip(pb, size - 52);
341 
342  /* scan primary file */
343  mlv->pb[100] = avctx->pb;
344  ret = scan_file(avctx, vst, ast, 100);
345  if (ret < 0)
346  return ret;
347 
348  /* scan secondary files */
349  if (strlen(avctx->url) > 2) {
350  int i;
351  char *filename = av_strdup(avctx->url);
352 
353  if (!filename)
354  return AVERROR(ENOMEM);
355 
356  for (i = 0; i < 100; i++) {
357  snprintf(filename + strlen(filename) - 2, 3, "%02d", i);
358  if (avctx->io_open(avctx, &mlv->pb[i], filename, AVIO_FLAG_READ, NULL) < 0)
359  break;
360  if (check_file_header(mlv->pb[i], guid) < 0) {
361  av_log(avctx, AV_LOG_WARNING, "ignoring %s; bad format or guid mismatch\n", filename);
362  ff_format_io_close(avctx, &mlv->pb[i]);
363  continue;
364  }
365  av_log(avctx, AV_LOG_INFO, "scanning %s\n", filename);
366  ret = scan_file(avctx, vst, ast, i);
367  if (ret < 0) {
368  av_log(avctx, AV_LOG_WARNING, "ignoring %s; %s\n", filename, av_err2str(ret));
369  ff_format_io_close(avctx, &mlv->pb[i]);
370  continue;
371  }
372  }
373  av_free(filename);
374  }
375 
376  if (vst)
377  vst->duration = vst->nb_index_entries;
378  if (ast)
379  ast->duration = ast->nb_index_entries;
380 
381  if ((vst && !vst->nb_index_entries) || (ast && !ast->nb_index_entries)) {
382  av_log(avctx, AV_LOG_ERROR, "no index entries found\n");
383  read_close(avctx);
384  return AVERROR_INVALIDDATA;
385  }
386 
387  if (vst && ast)
388  avio_seek(pb, FFMIN(vst->index_entries[0].pos, ast->index_entries[0].pos), SEEK_SET);
389  else if (vst)
390  avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
391  else if (ast)
392  avio_seek(pb, ast->index_entries[0].pos, SEEK_SET);
393 
394  return 0;
395 }
396 
398 {
399  MlvContext *mlv = avctx->priv_data;
400  AVIOContext *pb;
401  AVStream *st;
402  int index, ret;
403  unsigned int size, space;
404 
405  if (!avctx->nb_streams)
406  return AVERROR_EOF;
407 
408  st = avctx->streams[mlv->stream_index];
409  if (mlv->pts >= st->duration)
410  return AVERROR_EOF;
411 
412  index = av_index_search_timestamp(st, mlv->pts, AVSEEK_FLAG_ANY);
413  if (index < 0) {
414  av_log(avctx, AV_LOG_ERROR, "could not find index entry for frame %"PRId64"\n", mlv->pts);
415  return AVERROR(EIO);
416  }
417 
418  pb = mlv->pb[st->index_entries[index].size];
419  if (!pb) {
420  ret = FFERROR_REDO;
421  goto next_packet;
422  }
423  avio_seek(pb, st->index_entries[index].pos, SEEK_SET);
424 
425  avio_skip(pb, 4); // blockType
426  size = avio_rl32(pb);
427  if (size < 16)
428  return AVERROR_INVALIDDATA;
429  avio_skip(pb, 12); //timestamp, frameNumber
431  avio_skip(pb, 8); // cropPosX, cropPosY, panPosX, panPosY
432  space = avio_rl32(pb);
433  avio_skip(pb, space);
434 
435  if ((mlv->class[st->id] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA))) {
436  ret = AVERROR_PATCHWELCOME;
437  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
438  ret = av_get_packet(pb, pkt, (st->codecpar->width * st->codecpar->height * st->codecpar->bits_per_coded_sample + 7) >> 3);
439  } else { // AVMEDIA_TYPE_AUDIO
440  if (space > UINT_MAX - 24 || size < (24 + space))
441  return AVERROR_INVALIDDATA;
442  ret = av_get_packet(pb, pkt, size - (24 + space));
443  }
444 
445  if (ret < 0)
446  return ret;
447 
448  pkt->stream_index = mlv->stream_index;
449  pkt->pts = mlv->pts;
450 
451  ret = 0;
452 next_packet:
453  mlv->stream_index++;
454  if (mlv->stream_index == avctx->nb_streams) {
455  mlv->stream_index = 0;
456  mlv->pts++;
457  }
458  return ret;
459 }
460 
461 static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
462 {
463  MlvContext *mlv = avctx->priv_data;
464 
465  if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE))
466  return AVERROR(ENOSYS);
467 
468  if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
469  return AVERROR(EIO);
470 
471  mlv->pts = timestamp;
472  return 0;
473 }
474 
476 {
477  MlvContext *mlv = s->priv_data;
478  int i;
479  for (i = 0; i < 100; i++)
480  ff_format_io_close(s, &mlv->pb[i]);
481  return 0;
482 }
483 
485  .name = "mlv",
486  .long_name = NULL_IF_CONFIG_SMALL("Magic Lantern Video (MLV)"),
487  .priv_data_size = sizeof(MlvContext),
488  .read_probe = probe,
492  .read_seek = read_seek,
493 };
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:1933
#define NULL
Definition: coverity.c:32
static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
Definition: mlvdec.c:120
int stream_index
Definition: mlvdec.c:51
Bytestream IO Context.
Definition: avio.h:161
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static int check_file_header(AVIOContext *pb, uint64_t guid)
Definition: mlvdec.c:66
version
Definition: libkvazaar.c:292
int size
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
void avpriv_set_pts_info(AVStream *s, 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:4948
int64_t pos
Definition: avformat.h:805
#define MLV_CLASS_FLAG_LZMA
Definition: mlvdec.c:46
#define AVSEEK_FLAG_ANY
seek to any frame, even non-keyframes
Definition: avformat.h:2514
static int read_close(AVFormatContext *s)
Definition: mlvdec.c:475
#define avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
int num
Numerator.
Definition: rational.h:59
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:241
#define AVIO_FLAG_READ
read-only
Definition: avio.h:674
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:1105
static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: mlvdec.c:397
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:329
static AVPacket pkt
int framerate
Definition: h264_levels.c:65
#define MLV_CLASS_FLAG_DELTA
Definition: mlvdec.c:45
Format I/O context.
Definition: avformat.h:1351
uint8_t
#define av_malloc(s)
int width
Video only.
Definition: codec_par.h:126
int id
Format-specific stream ID.
Definition: avformat.h:883
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition: utils.c:5695
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4526
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data)...
Definition: internal.h:633
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1419
#define height
#define MLV_VIDEO_CLASS_RAW
Definition: mlvdec.c:38
uint32_t tag
Definition: movenc.c:1532
#define AVERROR_EOF
End of file.
Definition: error.h:55
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:307
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
Definition: riffdec.c:91
#define AVINDEX_KEYFRAME
Definition: avformat.h:812
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1591
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:2169
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:747
#define AVERROR(e)
Definition: error.h:43
static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, unsigned size)
Definition: mlvdec.c:82
#define MLV_VIDEO_CLASS_H264
Definition: mlvdec.c:41
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:188
char * url
input or output URL.
Definition: avformat.h:1447
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:616
static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
Definition: mlvdec.c:461
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:443
#define MLV_VIDEO_CLASS_YUV
Definition: mlvdec.c:39
AVIOContext * pb[101]
Definition: mlvdec.c:49
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1407
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:282
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:260
#define FFMIN(a, b)
Definition: common.h:96
AVInputFormat ff_mlv_demuxer
Definition: mlvdec.c:484
#define width
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that&#39;s been allocated with av_malloc() or another memory allocation functio...
Definition: dict.h:76
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:119
#define s(width, name)
Definition: cbs_vp9.c:257
#define AV_RL32
Definition: intreadwrite.h:146
#define MLV_VERSION
Definition: mlvdec.c:36
Stream structure.
Definition: avformat.h:876
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
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: utils.c:1993
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:253
AVIOContext * pb
I/O context.
Definition: avformat.h:1393
long long int64_t
Definition: coverity.c:34
static int probe(const AVProbeData *p)
Definition: mlvdec.c:57
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
int nb_index_entries
Definition: avformat.h:1107
double value
Definition: eval.c:98
static void read_uint32(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:110
int index
Definition: gxfenc.c:89
Rational number (pair of numerator and denominator).
Definition: rational.h:58
#define AVSEEK_FLAG_BYTE
seeking based on position in bytes
Definition: avformat.h:2513
cl_device_type type
#define snprintf
Definition: snprintf.h:34
static int read_header(AVFormatContext *avctx)
Definition: mlvdec.c:257
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:115
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:576
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:266
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:925
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:453
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:731
Main libavformat public API header.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Utilties for rational number calculation.
#define MLV_VIDEO_CLASS_JPEG
Definition: mlvdec.c:40
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
int64_t pos
position in the file of the current buffer
Definition: avio.h:238
int class[2]
Definition: mlvdec.c:50
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:927
int den
Denominator.
Definition: rational.h:60
unsigned int index_entries_allocated_size
Definition: avformat.h:1108
#define av_free(p)
#define MLV_AUDIO_CLASS_WAV
Definition: mlvdec.c:43
void * priv_data
Format private data.
Definition: avformat.h:1379
static void read_uint8(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:100
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
#define AVSEEK_FLAG_FRAME
seeking based on frame number
Definition: avformat.h:2515
uint64_t pts
Definition: mlvdec.c:52
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:650
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1023
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:356
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
int stream_index
Definition: packet.h:357
#define MKTAG(a, b, c, d)
Definition: common.h:406
This structure stores compressed data.
Definition: packet.h:332
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:755
static void read_uint16(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:105
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:348
simple arithmetic expression evaluator