FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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(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, int 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;
95  av_dict_set(&avctx->metadata, tag, value, AV_DICT_DONT_STRDUP_VAL);
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  MlvContext *mlv = avctx->priv_data;
121  AVIOContext *pb = mlv->pb[file];
122  int ret;
123  while (!avio_feof(pb)) {
124  int type;
125  unsigned int size;
126  type = avio_rl32(pb);
127  size = avio_rl32(pb);
128  avio_skip(pb, 8); //timestamp
129  if (size < 16)
130  break;
131  size -= 16;
132  if (vst && type == MKTAG('R','A','W','I') && size >= 164) {
133  vst->codec->width = avio_rl16(pb);
134  vst->codec->height = avio_rl16(pb);
135  ret = av_image_check_size(vst->codec->width, vst->codec->height, 0, avctx);
136  if (ret < 0)
137  return ret;
138  if (avio_rl32(pb) != 1)
139  avpriv_request_sample(avctx, "raw api version");
140  avio_skip(pb, 20); // pointer, width, height, pitch, frame_size
142  if (vst->codec->bits_per_coded_sample < 0 ||
143  vst->codec->bits_per_coded_sample > (INT_MAX - 7) / (vst->codec->width * vst->codec->height)) {
144  av_log(avctx, AV_LOG_ERROR,
145  "invalid bits_per_coded_sample %d (size: %dx%d)\n",
147  vst->codec->width, vst->codec->height);
148  return AVERROR_INVALIDDATA;
149  }
150  avio_skip(pb, 8 + 16 + 24); // black_level, white_level, xywh, active_area, exposure_bias
151  if (avio_rl32(pb) != 0x2010100) /* RGGB */
152  avpriv_request_sample(avctx, "cfa_pattern");
153  avio_skip(pb, 80); // calibration_illuminant1, color_matrix1, dynamic_range
155  vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16);
156  size -= 164;
157  } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) {
158  ret = ff_get_wav_header(avctx, pb, ast->codec, 16, 0);
159  if (ret < 0)
160  return ret;
161  size -= 16;
162  } else if (type == MKTAG('I','N','F','O')) {
163  if (size > 0)
164  read_string(avctx, pb, "info", size);
165  continue;
166  } else if (type == MKTAG('I','D','N','T') && size >= 36) {
167  read_string(avctx, pb, "cameraName", 32);
168  read_uint32(avctx, pb, "cameraModel", "0x%"PRIx32);
169  size -= 36;
170  if (size >= 32) {
171  read_string(avctx, pb, "cameraSerial", 32);
172  size -= 32;
173  }
174  } else if (type == MKTAG('L','E','N','S') && size >= 48) {
175  read_uint16(avctx, pb, "focalLength", "%i");
176  read_uint16(avctx, pb, "focalDist", "%i");
177  read_uint16(avctx, pb, "aperture", "%i");
178  read_uint8(avctx, pb, "stabilizerMode", "%i");
179  read_uint8(avctx, pb, "autofocusMode", "%i");
180  read_uint32(avctx, pb, "flags", "0x%"PRIx32);
181  read_uint32(avctx, pb, "lensID", "%"PRIi32);
182  read_string(avctx, pb, "lensName", 32);
183  size -= 48;
184  if (size >= 32) {
185  read_string(avctx, pb, "lensSerial", 32);
186  size -= 32;
187  }
188  } else if (vst && type == MKTAG('V', 'I', 'D', 'F') && size >= 4) {
189  uint64_t pts = avio_rl32(pb);
191  avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
192  size -= 4;
193  } else if (ast && type == MKTAG('A', 'U', 'D', 'F') && size >= 4) {
194  uint64_t pts = avio_rl32(pb);
196  avio_tell(pb) - 20, pts, file, 0, AVINDEX_KEYFRAME);
197  size -= 4;
198  } else if (vst && type == MKTAG('W','B','A','L') && size >= 28) {
199  read_uint32(avctx, pb, "wb_mode", "%"PRIi32);
200  read_uint32(avctx, pb, "kelvin", "%"PRIi32);
201  read_uint32(avctx, pb, "wbgain_r", "%"PRIi32);
202  read_uint32(avctx, pb, "wbgain_g", "%"PRIi32);
203  read_uint32(avctx, pb, "wbgain_b", "%"PRIi32);
204  read_uint32(avctx, pb, "wbs_gm", "%"PRIi32);
205  read_uint32(avctx, pb, "wbs_ba", "%"PRIi32);
206  size -= 28;
207  } else if (type == MKTAG('R','T','C','I') && size >= 20) {
208  char str[32];
209  struct tm time = { 0 };
210  time.tm_sec = avio_rl16(pb);
211  time.tm_min = avio_rl16(pb);
212  time.tm_hour = avio_rl16(pb);
213  time.tm_mday = avio_rl16(pb);
214  time.tm_mon = avio_rl16(pb);
215  time.tm_year = avio_rl16(pb);
216  time.tm_wday = avio_rl16(pb);
217  time.tm_yday = avio_rl16(pb);
218  time.tm_isdst = avio_rl16(pb);
219  avio_skip(pb, 2);
220  if (strftime(str, sizeof(str), "%Y-%m-%d %H:%M:%S", &time))
221  av_dict_set(&avctx->metadata, "time", str, 0);
222  size -= 20;
223  } else if (type == MKTAG('E','X','P','O') && size >= 16) {
224  av_dict_set(&avctx->metadata, "isoMode", avio_rl32(pb) ? "auto" : "manual", 0);
225  read_uint32(avctx, pb, "isoValue", "%"PRIi32);
226  read_uint32(avctx, pb, "isoAnalog", "%"PRIi32);
227  read_uint32(avctx, pb, "digitalGain", "%"PRIi32);
228  size -= 16;
229  if (size >= 8) {
230  read_uint64(avctx, pb, "shutterValue", "%"PRIi64);
231  size -= 8;
232  }
233  } else if (type == MKTAG('S','T','Y','L') && size >= 36) {
234  read_uint32(avctx, pb, "picStyleId", "%"PRIi32);
235  read_uint32(avctx, pb, "contrast", "%"PRIi32);
236  read_uint32(avctx, pb, "sharpness", "%"PRIi32);
237  read_uint32(avctx, pb, "saturation", "%"PRIi32);
238  read_uint32(avctx, pb, "colortone", "%"PRIi32);
239  read_string(avctx, pb, "picStyleName", 16);
240  size -= 36;
241  } else if (type == MKTAG('M','A','R','K')) {
242  } else if (type == MKTAG('N','U','L','L')) {
243  } else if (type == MKTAG('M','L','V','I')) { /* occurs when MLV and Mnn files are concatenated */
244  } else {
245  av_log(avctx, AV_LOG_INFO, "unsupported tag %c%c%c%c, size %u\n", type&0xFF, (type>>8)&0xFF, (type>>16)&0xFF, (type>>24)&0xFF, size);
246  }
247  avio_skip(pb, size);
248  }
249  return 0;
250 }
251 
252 static int read_header(AVFormatContext *avctx)
253 {
254  MlvContext *mlv = avctx->priv_data;
255  AVIOContext *pb = avctx->pb;
256  AVStream *vst = NULL, *ast = NULL;
257  int size, ret;
258  unsigned nb_video_frames, nb_audio_frames;
259  uint64_t guid;
260  char guidstr[32];
261 
262  avio_skip(pb, 4);
263  size = avio_rl32(pb);
264  if (size < 52)
265  return AVERROR_INVALIDDATA;
266 
267  avio_skip(pb, 8);
268 
269  guid = avio_rl64(pb);
270  snprintf(guidstr, sizeof(guidstr), "0x%"PRIx64, guid);
271  av_dict_set(&avctx->metadata, "guid", guidstr, 0);
272 
273  avio_skip(pb, 8); //fileNum, fileCount, fileFlags
274 
275  mlv->class[0] = avio_rl16(pb);
276  mlv->class[1] = avio_rl16(pb);
277 
278  nb_video_frames = avio_rl32(pb);
279  nb_audio_frames = avio_rl32(pb);
280 
281  if (nb_video_frames && mlv->class[0]) {
282  vst = avformat_new_stream(avctx, NULL);
283  if (!vst)
284  return AVERROR(ENOMEM);
285  vst->id = 0;
286  vst->nb_frames = nb_video_frames;
288  avpriv_request_sample(avctx, "compression");
290  switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)) {
291  case MLV_VIDEO_CLASS_RAW:
293  break;
294  case MLV_VIDEO_CLASS_YUV:
297  vst->codec->codec_tag = 0;
298  break;
301  vst->codec->codec_tag = 0;
302  break;
305  vst->codec->codec_tag = 0;
306  break;
307  default:
308  avpriv_request_sample(avctx, "unknown video class");
309  }
310  }
311 
312  if (nb_audio_frames && mlv->class[1]) {
313  ast = avformat_new_stream(avctx, NULL);
314  if (!ast)
315  return AVERROR(ENOMEM);
316  ast->id = 1;
317  ast->nb_frames = nb_audio_frames;
318  if ((mlv->class[1] & MLV_CLASS_FLAG_LZMA))
319  avpriv_request_sample(avctx, "compression");
320  if ((mlv->class[1] & ~MLV_CLASS_FLAG_LZMA) != MLV_AUDIO_CLASS_WAV)
321  avpriv_request_sample(avctx, "unknown audio class");
322 
323  ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
324  avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate);
325  }
326 
327  if (vst) {
328  AVRational framerate;
329  framerate.num = avio_rl32(pb);
330  framerate.den = avio_rl32(pb);
331  avpriv_set_pts_info(vst, 64, framerate.den, framerate.num);
332  } else
333  avio_skip(pb, 8);
334 
335  avio_skip(pb, size - 52);
336 
337  /* scan primary file */
338  mlv->pb[100] = avctx->pb;
339  ret = scan_file(avctx, vst, ast, 100);
340  if (ret < 0)
341  return ret;
342 
343  /* scan secondary files */
344  if (strlen(avctx->filename) > 2) {
345  int i;
346  char *filename = av_strdup(avctx->filename);
347 
348  if (!filename)
349  return AVERROR(ENOMEM);
350 
351  for (i = 0; i < 100; i++) {
352  snprintf(filename + strlen(filename) - 2, 3, "%02d", i);
353  if (avctx->io_open(avctx, &mlv->pb[i], filename, AVIO_FLAG_READ, NULL) < 0)
354  break;
355  if (check_file_header(mlv->pb[i], guid) < 0) {
356  av_log(avctx, AV_LOG_WARNING, "ignoring %s; bad format or guid mismatch\n", filename);
357  ff_format_io_close(avctx, &mlv->pb[i]);
358  continue;
359  }
360  av_log(avctx, AV_LOG_INFO, "scanning %s\n", filename);
361  ret = scan_file(avctx, vst, ast, i);
362  if (ret < 0) {
363  av_log(avctx, AV_LOG_WARNING, "ignoring %s; %s\n", filename, av_err2str(ret));
364  ff_format_io_close(avctx, &mlv->pb[i]);
365  continue;
366  }
367  }
368  av_free(filename);
369  }
370 
371  if (vst)
372  vst->duration = vst->nb_index_entries;
373  if (ast)
374  ast->duration = ast->nb_index_entries;
375 
376  if ((vst && !vst->nb_index_entries) || (ast && !ast->nb_index_entries)) {
377  av_log(avctx, AV_LOG_ERROR, "no index entries found\n");
378  return AVERROR_INVALIDDATA;
379  }
380 
381  if (vst && ast)
382  avio_seek(pb, FFMIN(vst->index_entries[0].pos, ast->index_entries[0].pos), SEEK_SET);
383  else if (vst)
384  avio_seek(pb, vst->index_entries[0].pos, SEEK_SET);
385  else if (ast)
386  avio_seek(pb, ast->index_entries[0].pos, SEEK_SET);
387 
388  return 0;
389 }
390 
392 {
393  MlvContext *mlv = avctx->priv_data;
394  AVIOContext *pb;
395  AVStream *st = avctx->streams[mlv->stream_index];
396  int index, ret;
397  unsigned int size, space;
398 
399  if (mlv->pts >= st->duration)
400  return AVERROR_EOF;
401 
402  index = av_index_search_timestamp(st, mlv->pts, AVSEEK_FLAG_ANY);
403  if (index < 0) {
404  av_log(avctx, AV_LOG_ERROR, "could not find index entry for frame %"PRId64"\n", mlv->pts);
405  return AVERROR(EIO);
406  }
407 
408  pb = mlv->pb[st->index_entries[index].size];
409  avio_seek(pb, st->index_entries[index].pos, SEEK_SET);
410 
411  avio_skip(pb, 4); // blockType
412  size = avio_rl32(pb);
413  if (size < 16)
414  return AVERROR_INVALIDDATA;
415  avio_skip(pb, 12); //timestamp, frameNumber
416  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
417  avio_skip(pb, 8); // cropPosX, cropPosY, panPosX, panPosY
418  space = avio_rl32(pb);
419  avio_skip(pb, space);
420 
421  if ((mlv->class[st->id] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA))) {
422  ret = AVERROR_PATCHWELCOME;
423  } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
424  ret = av_get_packet(pb, pkt, (st->codec->width * st->codec->height * st->codec->bits_per_coded_sample + 7) >> 3);
425  } else { // AVMEDIA_TYPE_AUDIO
426  if (space > UINT_MAX - 24 || size < (24 + space))
427  return AVERROR_INVALIDDATA;
428  ret = av_get_packet(pb, pkt, size - (24 + space));
429  }
430 
431  if (ret < 0)
432  return ret;
433 
434  pkt->stream_index = mlv->stream_index;
435  pkt->pts = mlv->pts;
436 
437  mlv->stream_index++;
438  if (mlv->stream_index == avctx->nb_streams) {
439  mlv->stream_index = 0;
440  mlv->pts++;
441  }
442  return 0;
443 }
444 
445 static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
446 {
447  MlvContext *mlv = avctx->priv_data;
448 
449  if ((flags & AVSEEK_FLAG_FRAME) || (flags & AVSEEK_FLAG_BYTE))
450  return AVERROR(ENOSYS);
451 
452  if (!avctx->pb->seekable)
453  return AVERROR(EIO);
454 
455  mlv->pts = timestamp;
456  return 0;
457 }
458 
460 {
461  MlvContext *mlv = s->priv_data;
462  int i;
463  for (i = 0; i < 100; i++)
464  if (mlv->pb[i])
465  ff_format_io_close(s, &mlv->pb[i]);
466  return 0;
467 }
468 
470  .name = "mlv",
471  .long_name = NULL_IF_CONFIG_SMALL("Magic Lantern Video (MLV)"),
472  .priv_data_size = sizeof(MlvContext),
473  .read_probe = probe,
477  .read_seek = read_seek,
478 };
#define NULL
Definition: coverity.c:32
static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
Definition: mlvdec.c:118
int stream_index
Definition: mlvdec.c:51
const char * s
Definition: avisynth_c.h:631
Bytestream IO Context.
Definition: avio.h:111
#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:64
const char * fmt
Definition: avisynth_c.h:632
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:4149
int64_t pos
Definition: avformat.h:817
#define MLV_CLASS_FLAG_LZMA
Definition: mlvdec.c:46
#define AVSEEK_FLAG_ANY
seek to any frame, even non-keyframes
Definition: avformat.h:2350
static int read_close(AVFormatContext *s)
Definition: mlvdec.c:459
int num
numerator
Definition: rational.h:44
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:208
#define AVIO_FLAG_READ
read-only
Definition: avio.h:537
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:1080
static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: mlvdec.c:391
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1752
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:282
int version
Definition: avisynth_c.h:629
static AVPacket pkt
#define MLV_CLASS_FLAG_DELTA
Definition: mlvdec.c:45
Format I/O context.
Definition: avformat.h:1314
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t
#define av_malloc(s)
int id
Format-specific stream ID.
Definition: avformat.h:884
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition: utils.c:4736
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:3805
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1382
#define MLV_VIDEO_CLASS_RAW
Definition: mlvdec.c:38
uint32_t tag
Definition: movenc.c:1348
#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:252
ptrdiff_t size
Definition: opengl_enc.c:101
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:442
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:2917
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:545
#define AVINDEX_KEYFRAME
Definition: avformat.h:824
#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:1528
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:1877
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:667
#define AVERROR(e)
Definition: error.h:43
#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:176
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:536
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:896
static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
Definition: mlvdec.c:445
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:462
#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:1370
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:251
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:207
char filename[1024]
input or output filename
Definition: avformat.h:1390
#define FFMIN(a, b)
Definition: common.h:96
AVInputFormat ff_mlv_demuxer
Definition: mlvdec.c:469
#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:78
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
int width
picture width / height.
Definition: avcodec.h:1711
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:109
static void read_string(AVFormatContext *avctx, AVIOContext *pb, const char *tag, int size)
Definition: mlvdec.c:80
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 MLV_VERSION
Definition: mlvdec.c:36
Stream structure.
Definition: avformat.h:877
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#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:1719
enum AVMediaType codec_type
Definition: avcodec.h:1540
enum AVCodecID codec_id
Definition: avcodec.h:1549
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:267
AVIOContext * pb
I/O context.
Definition: avformat.h:1356
static int probe(AVProbeData *p)
Definition: mlvdec.c:55
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1564
GLint GLenum type
Definition: opengl_enc.c:105
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:69
int nb_index_entries
Definition: avformat.h:1082
static void read_uint32(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:108
int index
Definition: gxfenc.c:89
rational number numerator/denominator
Definition: rational.h:43
#define AVSEEK_FLAG_BYTE
seeking based on position in bytes
Definition: avformat.h:2349
#define snprintf
Definition: snprintf.h:34
static int read_header(AVFormatContext *avctx)
Definition: mlvdec.c:252
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian)
Definition: riffdec.c:88
This structure contains the data a format has to probe a file.
Definition: avformat.h:460
static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:113
static int64_t pts
Global timestamp for the audio frames.
static int flags
Definition: cpu.c:47
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian */
Definition: pixfmt.h:274
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:936
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:472
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:651
Main libavformat public API header.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:63
rational numbers
#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:143
int64_t pos
position in the file of the current buffer
Definition: avio.h:184
int class[2]
Definition: mlvdec.c:50
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:938
int den
denominator
Definition: rational.h:45
unsigned int index_entries_allocated_size
Definition: avformat.h:1083
#define av_free(p)
#define MLV_AUDIO_CLASS_WAV
Definition: mlvdec.c:43
void * priv_data
Format private data.
Definition: avformat.h:1342
static void read_uint8(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:98
#define AVSEEK_FLAG_FRAME
seeking based on frame number
Definition: avformat.h:2351
uint64_t pts
Definition: mlvdec.c:52
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:661
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:306
int stream_index
Definition: avcodec.h:1469
#define MKTAG(a, b, c, d)
Definition: common.h:342
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
Definition: avformat.h:1872
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:87
This structure stores compressed data.
Definition: avcodec.h:1444
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:675
static void read_uint16(AVFormatContext *avctx, AVIOContext *pb, const char *tag, const char *fmt)
Definition: mlvdec.c:103
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1460
simple arithmetic expression evaluator