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