FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
img2dec.c
Go to the documentation of this file.
1 /*
2  * Image format
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  * Copyright (c) 2004 Michael Niedermayer
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #define _DEFAULT_SOURCE
24 #define _BSD_SOURCE
25 #include <sys/stat.h>
26 #include "libavutil/avstring.h"
27 #include "libavutil/log.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/pixdesc.h"
30 #include "libavutil/parseutils.h"
31 #include "libavutil/intreadwrite.h"
32 #include "avformat.h"
33 #include "avio_internal.h"
34 #include "internal.h"
35 #include "img2.h"
36 #include "libavcodec/mjpeg.h"
37 #include "subtitles.h"
38 
39 #if HAVE_GLOB
40 /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
41  are non-posix glibc/bsd extensions. */
42 #ifndef GLOB_NOMAGIC
43 #define GLOB_NOMAGIC 0
44 #endif
45 #ifndef GLOB_BRACE
46 #define GLOB_BRACE 0
47 #endif
48 
49 #endif /* HAVE_GLOB */
50 
51 static const int sizes[][2] = {
52  { 640, 480 },
53  { 720, 480 },
54  { 720, 576 },
55  { 352, 288 },
56  { 352, 240 },
57  { 160, 128 },
58  { 512, 384 },
59  { 640, 352 },
60  { 640, 240 },
61 };
62 
63 static int infer_size(int *width_ptr, int *height_ptr, int size)
64 {
65  int i;
66 
67  for (i = 0; i < FF_ARRAY_ELEMS(sizes); i++) {
68  if ((sizes[i][0] * sizes[i][1]) == size) {
69  *width_ptr = sizes[i][0];
70  *height_ptr = sizes[i][1];
71  return 0;
72  }
73  }
74 
75  return -1;
76 }
77 
78 static int is_glob(const char *path)
79 {
80 #if HAVE_GLOB
81  size_t span = 0;
82  const char *p = path;
83 
84  while (p = strchr(p, '%')) {
85  if (*(++p) == '%') {
86  ++p;
87  continue;
88  }
89  if (span = strspn(p, "*?[]{}"))
90  break;
91  }
92  /* Did we hit a glob char or get to the end? */
93  return span != 0;
94 #else
95  return 0;
96 #endif
97 }
98 
99 /**
100  * Get index range of image files matched by path.
101  *
102  * @param pfirst_index pointer to index updated with the first number in the range
103  * @param plast_index pointer to index updated with the last number in the range
104  * @param path path which has to be matched by the image files in the range
105  * @param start_index minimum accepted value for the first index in the range
106  * @return -1 if no image file could be found
107  */
108 static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index,
109  const char *path, int start_index, int start_index_range)
110 {
111  char buf[1024];
112  int range, last_index, range1, first_index;
113 
114  /* find the first image */
115  for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
116  if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
117  *pfirst_index =
118  *plast_index = 1;
119  if (pb || avio_check(buf, AVIO_FLAG_READ) > 0)
120  return 0;
121  return -1;
122  }
123  if (avio_check(buf, AVIO_FLAG_READ) > 0)
124  break;
125  }
126  if (first_index == start_index + start_index_range)
127  goto fail;
128 
129  /* find the last image */
130  last_index = first_index;
131  for (;;) {
132  range = 0;
133  for (;;) {
134  if (!range)
135  range1 = 1;
136  else
137  range1 = 2 * range;
138  if (av_get_frame_filename(buf, sizeof(buf), path,
139  last_index + range1) < 0)
140  goto fail;
141  if (avio_check(buf, AVIO_FLAG_READ) <= 0)
142  break;
143  range = range1;
144  /* just in case... */
145  if (range >= (1 << 30))
146  goto fail;
147  }
148  /* we are sure than image last_index + range exists */
149  if (!range)
150  break;
151  last_index += range;
152  }
153  *pfirst_index = first_index;
154  *plast_index = last_index;
155  return 0;
156 
157 fail:
158  return -1;
159 }
160 
162 {
163  if (p->filename && ff_guess_image2_codec(p->filename)) {
165  return AVPROBE_SCORE_MAX;
166  else if (is_glob(p->filename))
167  return AVPROBE_SCORE_MAX;
168  else if (p->filename[strcspn(p->filename, "*?{")]) // probably PT_GLOB
169  return AVPROBE_SCORE_EXTENSION + 2; // score chosen to be a tad above the image pipes
170  else if (p->buf_size == 0)
171  return 0;
172  else if (av_match_ext(p->filename, "raw") || av_match_ext(p->filename, "gif"))
173  return 5;
174  else
176  }
177  return 0;
178 }
179 
181 {
182  VideoDemuxData *s = s1->priv_data;
183  int first_index = 1, last_index = 1;
184  AVStream *st;
186 
188 
189  st = avformat_new_stream(s1, NULL);
190  if (!st) {
191  return AVERROR(ENOMEM);
192  }
193 
194  if (s->pixel_format &&
195  (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) {
196  av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n",
197  s->pixel_format);
198  return AVERROR(EINVAL);
199  }
200 
201  av_strlcpy(s->path, s1->url, sizeof(s->path));
202  s->img_number = 0;
203  s->img_count = 0;
204 
205  /* find format */
206  if (s1->iformat->flags & AVFMT_NOFILE)
207  s->is_pipe = 0;
208  else {
209  s->is_pipe = 1;
211  }
212 
213  if (s->ts_from_file == 2) {
214 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
215  av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
216  return AVERROR(ENOSYS);
217 #endif
218  avpriv_set_pts_info(st, 64, 1, 1000000000);
219  } else if (s->ts_from_file)
220  avpriv_set_pts_info(st, 64, 1, 1);
221  else
223 
224  if (s->width && s->height) {
225  st->codecpar->width = s->width;
226  st->codecpar->height = s->height;
227  }
228 
229  if (!s->is_pipe) {
230  if (s->pattern_type == PT_DEFAULT) {
231  if (s1->pb) {
232  s->pattern_type = PT_NONE;
233  } else
235  }
236 
237  if (s->pattern_type == PT_GLOB_SEQUENCE) {
238  s->use_glob = is_glob(s->path);
239  if (s->use_glob) {
240 #if HAVE_GLOB
241  char *p = s->path, *q, *dup;
242  int gerr;
243 #endif
244 
245  av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: "
246  "use pattern_type 'glob' instead\n");
247 #if HAVE_GLOB
248  dup = q = av_strdup(p);
249  while (*q) {
250  /* Do we have room for the next char and a \ insertion? */
251  if ((p - s->path) >= (sizeof(s->path) - 2))
252  break;
253  if (*q == '%' && strspn(q + 1, "%*?[]{}"))
254  ++q;
255  else if (strspn(q, "\\*?[]{}"))
256  *p++ = '\\';
257  *p++ = *q++;
258  }
259  *p = 0;
260  av_free(dup);
261 
262  gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
263  if (gerr != 0) {
264  return AVERROR(ENOENT);
265  }
266  first_index = 0;
267  last_index = s->globstate.gl_pathc - 1;
268 #endif
269  }
270  }
271  if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) {
272  if (find_image_range(s1->pb, &first_index, &last_index, s->path,
273  s->start_number, s->start_number_range) < 0) {
274  av_log(s1, AV_LOG_ERROR,
275  "Could find no file with path '%s' and index in the range %d-%d\n",
276  s->path, s->start_number, s->start_number + s->start_number_range - 1);
277  return AVERROR(ENOENT);
278  }
279  } else if (s->pattern_type == PT_GLOB) {
280 #if HAVE_GLOB
281  int gerr;
282  gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
283  if (gerr != 0) {
284  return AVERROR(ENOENT);
285  }
286  first_index = 0;
287  last_index = s->globstate.gl_pathc - 1;
288  s->use_glob = 1;
289 #else
290  av_log(s1, AV_LOG_ERROR,
291  "Pattern type 'glob' was selected but globbing "
292  "is not supported by this libavformat build\n");
293  return AVERROR(ENOSYS);
294 #endif
295  } else if (s->pattern_type != PT_GLOB_SEQUENCE && s->pattern_type != PT_NONE) {
296  av_log(s1, AV_LOG_ERROR,
297  "Unknown value '%d' for pattern_type option\n", s->pattern_type);
298  return AVERROR(EINVAL);
299  }
300  s->img_first = first_index;
301  s->img_last = last_index;
302  s->img_number = first_index;
303  /* compute duration */
304  if (!s->ts_from_file) {
305  st->start_time = 0;
306  st->duration = last_index - first_index + 1;
307  }
308  }
309 
310  if (s1->video_codec_id) {
312  st->codecpar->codec_id = s1->video_codec_id;
313  } else if (s1->audio_codec_id) {
315  st->codecpar->codec_id = s1->audio_codec_id;
316  } else if (s1->iformat->raw_codec_id) {
319  } else {
320  const char *str = strrchr(s->path, '.');
321  s->split_planes = str && !av_strcasecmp(str + 1, "y");
323  if (s1->pb) {
324  int probe_buffer_size = 2048;
325  uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE);
326  const AVInputFormat *fmt = NULL;
327  void *fmt_iter = NULL;
328  AVProbeData pd = { 0 };
329 
330  if (!probe_buffer)
331  return AVERROR(ENOMEM);
332 
333  probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size);
334  if (probe_buffer_size < 0) {
335  av_free(probe_buffer);
336  return probe_buffer_size;
337  }
338  memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE);
339 
340  pd.buf = probe_buffer;
341  pd.buf_size = probe_buffer_size;
342  pd.filename = s1->url;
343 
344  while ((fmt = av_demuxer_iterate(&fmt_iter))) {
345  if (fmt->read_header != ff_img_read_header ||
346  !fmt->read_probe ||
347  (fmt->flags & AVFMT_NOFILE) ||
348  !fmt->raw_codec_id)
349  continue;
350  if (fmt->read_probe(&pd) > 0) {
351  st->codecpar->codec_id = fmt->raw_codec_id;
352  break;
353  }
354  }
355  if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
356  avio_seek(s1->pb, 0, SEEK_SET);
357  } else
358  ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
359  }
360  if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
362  if (st->codecpar->codec_id == AV_CODEC_ID_LJPEG)
364  if (st->codecpar->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX
366  }
367  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
368  pix_fmt != AV_PIX_FMT_NONE)
369  st->codecpar->format = pix_fmt;
370 
371  return 0;
372 }
373 
375 {
376  VideoDemuxData *s = s1->priv_data;
377  char filename_bytes[1024];
378  char *filename = filename_bytes;
379  int i, res;
380  int size[3] = { 0 }, ret[3] = { 0 };
381  AVIOContext *f[3] = { NULL };
382  AVCodecParameters *par = s1->streams[0]->codecpar;
383 
384  if (!s->is_pipe) {
385  /* loop over input */
386  if (s->loop && s->img_number > s->img_last) {
387  s->img_number = s->img_first;
388  }
389  if (s->img_number > s->img_last)
390  return AVERROR_EOF;
391  if (s->pattern_type == PT_NONE) {
392  av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes));
393  } else if (s->use_glob) {
394 #if HAVE_GLOB
395  filename = s->globstate.gl_pathv[s->img_number];
396 #endif
397  } else {
398  if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes),
399  s->path,
400  s->img_number) < 0 && s->img_number > 1)
401  return AVERROR(EIO);
402  }
403  for (i = 0; i < 3; i++) {
404  if (s1->pb &&
405  !strcmp(filename_bytes, s->path) &&
406  !s->loop &&
407  !s->split_planes) {
408  f[i] = s1->pb;
409  } else if (s1->io_open(s1, &f[i], filename, AVIO_FLAG_READ, NULL) < 0) {
410  if (i >= 1)
411  break;
412  av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",
413  filename);
414  return AVERROR(EIO);
415  }
416  size[i] = avio_size(f[i]);
417 
418  if (!s->split_planes)
419  break;
420  filename[strlen(filename) - 1] = 'U' + i;
421  }
422 
423  if (par->codec_id == AV_CODEC_ID_NONE) {
424  AVProbeData pd = { 0 };
425  AVInputFormat *ifmt;
427  int ret;
428  int score = 0;
429 
430  ret = avio_read(f[0], header, PROBE_BUF_MIN);
431  if (ret < 0)
432  return ret;
433  memset(header + ret, 0, sizeof(header) - ret);
434  avio_skip(f[0], -ret);
435  pd.buf = header;
436  pd.buf_size = ret;
437  pd.filename = filename;
438 
439  ifmt = av_probe_input_format3(&pd, 1, &score);
440  if (ifmt && ifmt->read_packet == ff_img_read_packet && ifmt->raw_codec_id)
441  par->codec_id = ifmt->raw_codec_id;
442  }
443 
444  if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
445  infer_size(&par->width, &par->height, size[0]);
446  } else {
447  f[0] = s1->pb;
448  if (avio_feof(f[0]) && s->loop && s->is_pipe)
449  avio_seek(f[0], 0, SEEK_SET);
450  if (avio_feof(f[0]))
451  return AVERROR_EOF;
452  if (s->frame_size > 0) {
453  size[0] = s->frame_size;
454  } else if (!s1->streams[0]->parser) {
455  size[0] = avio_size(s1->pb);
456  } else {
457  size[0] = 4096;
458  }
459  }
460 
461  res = av_new_packet(pkt, size[0] + size[1] + size[2]);
462  if (res < 0) {
463  goto fail;
464  }
465  pkt->stream_index = 0;
466  pkt->flags |= AV_PKT_FLAG_KEY;
467  if (s->ts_from_file) {
468  struct stat img_stat;
469  if (stat(filename, &img_stat)) {
470  res = AVERROR(EIO);
471  goto fail;
472  }
473  pkt->pts = (int64_t)img_stat.st_mtime;
474 #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
475  if (s->ts_from_file == 2)
476  pkt->pts = 1000000000*pkt->pts + img_stat.st_mtim.tv_nsec;
477 #endif
478  av_add_index_entry(s1->streams[0], s->img_number, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
479  } else if (!s->is_pipe) {
480  pkt->pts = s->pts;
481  }
482 
483  if (s->is_pipe)
484  pkt->pos = avio_tell(f[0]);
485 
486  pkt->size = 0;
487  for (i = 0; i < 3; i++) {
488  if (f[i]) {
489  ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
490  if (s->loop && s->is_pipe && ret[i] == AVERROR_EOF) {
491  if (avio_seek(f[i], 0, SEEK_SET) >= 0) {
492  pkt->pos = 0;
493  ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
494  }
495  }
496  if (!s->is_pipe && f[i] != s1->pb)
497  ff_format_io_close(s1, &f[i]);
498  if (ret[i] > 0)
499  pkt->size += ret[i];
500  }
501  }
502 
503  if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
504  av_packet_unref(pkt);
505  if (ret[0] < 0) {
506  res = ret[0];
507  } else if (ret[1] < 0) {
508  res = ret[1];
509  } else if (ret[2] < 0) {
510  res = ret[2];
511  } else {
512  res = AVERROR_EOF;
513  }
514  goto fail;
515  } else {
516  s->img_count++;
517  s->img_number++;
518  s->pts++;
519  return 0;
520  }
521 
522 fail:
523  if (!s->is_pipe) {
524  for (i = 0; i < 3; i++) {
525  if (f[i] != s1->pb)
526  ff_format_io_close(s1, &f[i]);
527  }
528  }
529  return res;
530 }
531 
532 static int img_read_close(struct AVFormatContext* s1)
533 {
534 #if HAVE_GLOB
535  VideoDemuxData *s = s1->priv_data;
536  if (s->use_glob) {
537  globfree(&s->globstate);
538  }
539 #endif
540  return 0;
541 }
542 
543 static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
544 {
546  AVStream *st = s->streams[0];
547 
548  if (s1->ts_from_file) {
549  int index = av_index_search_timestamp(st, timestamp, flags);
550  if(index < 0)
551  return -1;
552  s1->img_number = st->index_entries[index].pos;
553  return 0;
554  }
555 
556  if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first)
557  return -1;
558  s1->img_number = timestamp%(s1->img_last - s1->img_first + 1) + s1->img_first;
559  s1->pts = timestamp;
560  return 0;
561 }
562 
563 #define OFFSET(x) offsetof(VideoDemuxData, x)
564 #define DEC AV_OPT_FLAG_DECODING_PARAM
566  { "framerate", "set the video framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC },
567  { "loop", "force loop over input file sequence", OFFSET(loop), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC },
568 
569  { "pattern_type", "set pattern type", OFFSET(pattern_type), AV_OPT_TYPE_INT, {.i64=PT_DEFAULT}, 0, INT_MAX, DEC, "pattern_type"},
570  { "glob_sequence","select glob/sequence pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX, DEC, "pattern_type" },
571  { "glob", "select glob pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX, DEC, "pattern_type" },
572  { "sequence", "select sequence pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX, DEC, "pattern_type" },
573  { "none", "disable pattern matching", 0, AV_OPT_TYPE_CONST, {.i64=PT_NONE }, INT_MIN, INT_MAX, DEC, "pattern_type" },
574 
575  { "pixel_format", "set video pixel format", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
576  { "start_number", "set first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, DEC },
577  { "start_number_range", "set range for looking at the first sequence number", OFFSET(start_number_range), AV_OPT_TYPE_INT, {.i64 = 5}, 1, INT_MAX, DEC },
578  { "video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
579  { "frame_size", "force frame size in bytes", OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, DEC },
580  { "ts_from_file", "set frame timestamp from file's one", OFFSET(ts_from_file), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "ts_type" },
581  { "none", "none", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 2, DEC, "ts_type" },
582  { "sec", "second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 2, DEC, "ts_type" },
583  { "ns", "nano second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 2, DEC, "ts_type" },
584  { NULL },
585 };
586 
587 #if CONFIG_IMAGE2_DEMUXER
588 static const AVClass img2_class = {
589  .class_name = "image2 demuxer",
590  .item_name = av_default_item_name,
591  .option = ff_img_options,
592  .version = LIBAVUTIL_VERSION_INT,
593 };
595  .name = "image2",
596  .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"),
597  .priv_data_size = sizeof(VideoDemuxData),
603  .flags = AVFMT_NOFILE,
604  .priv_class = &img2_class,
605 };
606 #endif
607 #if CONFIG_IMAGE2PIPE_DEMUXER
608 static const AVClass img2pipe_class = {
609  .class_name = "image2pipe demuxer",
610  .item_name = av_default_item_name,
611  .option = ff_img_options,
612  .version = LIBAVUTIL_VERSION_INT,
613 };
615  .name = "image2pipe",
616  .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"),
617  .priv_data_size = sizeof(VideoDemuxData),
620  .priv_class = &img2pipe_class,
621 };
622 #endif
623 
624 static int bmp_probe(AVProbeData *p)
625 {
626  const uint8_t *b = p->buf;
627  int ihsize;
628 
629  if (AV_RB16(b) != 0x424d)
630  return 0;
631 
632  ihsize = AV_RL32(b+14);
633  if (ihsize < 12 || ihsize > 255)
634  return 0;
635 
636  if (!AV_RN32(b + 6)) {
637  return AVPROBE_SCORE_EXTENSION + 1;
638  }
639  return AVPROBE_SCORE_EXTENSION / 4;
640 }
641 
642 static int dds_probe(AVProbeData *p)
643 {
644  const uint8_t *b = p->buf;
645 
646  if ( AV_RB64(b) == 0x444453207c000000
647  && AV_RL32(b + 8)
648  && AV_RL32(b + 12))
649  return AVPROBE_SCORE_MAX - 1;
650  return 0;
651 }
652 
653 static int dpx_probe(AVProbeData *p)
654 {
655  const uint8_t *b = p->buf;
656  int w, h;
657  int is_big = (AV_RN32(b) == AV_RN32("SDPX"));
658 
659  if (p->buf_size < 0x304+8)
660  return 0;
661  w = is_big ? AV_RB32(p->buf + 0x304) : AV_RL32(p->buf + 0x304);
662  h = is_big ? AV_RB32(p->buf + 0x308) : AV_RL32(p->buf + 0x308);
663  if (w <= 0 || h <= 0)
664  return 0;
665 
666  if (is_big || AV_RN32(b) == AV_RN32("XPDS"))
667  return AVPROBE_SCORE_EXTENSION + 1;
668  return 0;
669 }
670 
671 static int exr_probe(AVProbeData *p)
672 {
673  const uint8_t *b = p->buf;
674 
675  if (AV_RL32(b) == 20000630)
676  return AVPROBE_SCORE_EXTENSION + 1;
677  return 0;
678 }
679 
680 static int j2k_probe(AVProbeData *p)
681 {
682  const uint8_t *b = p->buf;
683 
684  if (AV_RB64(b) == 0x0000000c6a502020 ||
685  AV_RB32(b) == 0xff4fff51)
686  return AVPROBE_SCORE_EXTENSION + 1;
687  return 0;
688 }
689 
690 static int jpeg_probe(AVProbeData *p)
691 {
692  const uint8_t *b = p->buf;
693  int i, state = SOI;
694 
695  if (AV_RB16(b) != 0xFFD8 ||
696  AV_RB32(b) == 0xFFD8FFF7)
697  return 0;
698 
699  b += 2;
700  for (i = 0; i < p->buf_size - 3; i++) {
701  int c;
702  if (b[i] != 0xFF)
703  continue;
704  c = b[i + 1];
705  switch (c) {
706  case SOI:
707  return 0;
708  case SOF0:
709  case SOF1:
710  case SOF2:
711  case SOF3:
712  case SOF5:
713  case SOF6:
714  case SOF7:
715  i += AV_RB16(&b[i + 2]) + 1;
716  if (state != SOI)
717  return 0;
718  state = SOF0;
719  break;
720  case SOS:
721  i += AV_RB16(&b[i + 2]) + 1;
722  if (state != SOF0 && state != SOS)
723  return 0;
724  state = SOS;
725  break;
726  case EOI:
727  if (state != SOS)
728  return 0;
729  state = EOI;
730  break;
731  case DQT:
732  case APP0:
733  case APP1:
734  case APP2:
735  case APP3:
736  case APP4:
737  case APP5:
738  case APP6:
739  case APP7:
740  case APP8:
741  case APP9:
742  case APP10:
743  case APP11:
744  case APP12:
745  case APP13:
746  case APP14:
747  case APP15:
748  case COM:
749  i += AV_RB16(&b[i + 2]) + 1;
750  break;
751  default:
752  if ( (c > TEM && c < SOF0)
753  || c == JPG)
754  return 0;
755  }
756  }
757 
758  if (state == EOI)
759  return AVPROBE_SCORE_EXTENSION + 1;
760  if (state == SOS)
761  return AVPROBE_SCORE_EXTENSION / 2;
762  return AVPROBE_SCORE_EXTENSION / 8;
763 }
764 
765 static int jpegls_probe(AVProbeData *p)
766 {
767  const uint8_t *b = p->buf;
768 
769  if (AV_RB32(b) == 0xffd8fff7)
770  return AVPROBE_SCORE_EXTENSION + 1;
771  return 0;
772 }
773 
774 static int pcx_probe(AVProbeData *p)
775 {
776  const uint8_t *b = p->buf;
777 
778  if ( p->buf_size < 128
779  || b[0] != 10
780  || b[1] > 5
781  || b[2] > 1
782  || av_popcount(b[3]) != 1 || b[3] > 8
783  || AV_RL16(&b[4]) > AV_RL16(&b[8])
784  || AV_RL16(&b[6]) > AV_RL16(&b[10])
785  || b[64])
786  return 0;
787  b += 73;
788  while (++b < p->buf + 128)
789  if (*b)
790  return AVPROBE_SCORE_EXTENSION / 4;
791 
792  return AVPROBE_SCORE_EXTENSION + 1;
793 }
794 
795 static int qdraw_probe(AVProbeData *p)
796 {
797  const uint8_t *b = p->buf;
798 
799  if ( p->buf_size >= 528
800  && (AV_RB64(b + 520) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
801  && AV_RB16(b + 520)
802  && AV_RB16(b + 518))
803  return AVPROBE_SCORE_MAX * 3 / 4;
804  if ( (AV_RB64(b + 8) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
805  && AV_RB16(b + 8)
806  && AV_RB16(b + 6))
807  return AVPROBE_SCORE_EXTENSION / 4;
808  return 0;
809 }
810 
811 static int pictor_probe(AVProbeData *p)
812 {
813  const uint8_t *b = p->buf;
814 
815  if (AV_RL16(b) == 0x1234)
816  return AVPROBE_SCORE_EXTENSION / 4;
817  return 0;
818 }
819 
820 static int png_probe(AVProbeData *p)
821 {
822  const uint8_t *b = p->buf;
823 
824  if (AV_RB64(b) == 0x89504e470d0a1a0a)
825  return AVPROBE_SCORE_MAX - 1;
826  return 0;
827 }
828 
829 static int psd_probe(AVProbeData *p)
830 {
831  const uint8_t *b = p->buf;
832  int ret = 0;
833  uint16_t color_mode;
834 
835  if (AV_RL32(b) == MKTAG('8','B','P','S')) {
836  ret += 1;
837  } else {
838  return 0;
839  }
840 
841  if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */
842  ret += 1;
843  } else {
844  return 0;
845  }
846 
847  if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */
848  ret += 1;
849 
850  color_mode = AV_RB16(b+24);
851  if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6))
852  ret += 1;
853 
854  return AVPROBE_SCORE_EXTENSION + ret;
855 }
856 
857 static int sgi_probe(AVProbeData *p)
858 {
859  const uint8_t *b = p->buf;
860 
861  if (AV_RB16(b) == 474 &&
862  (b[2] & ~1) == 0 &&
863  (b[3] & ~3) == 0 && b[3] &&
864  (AV_RB16(b + 4) & ~7) == 0 && AV_RB16(b + 4))
865  return AVPROBE_SCORE_EXTENSION + 1;
866  return 0;
867 }
868 
870 {
871  const uint8_t *b = p->buf;
872 
873  if (AV_RB32(b) == 0x59a66a95)
874  return AVPROBE_SCORE_EXTENSION + 1;
875  return 0;
876 }
877 
878 static int svg_probe(AVProbeData *p)
879 {
880  const uint8_t *b = p->buf;
881  const uint8_t *end = p->buf + p->buf_size;
882 
883  if (memcmp(p->buf, "<?xml", 5))
884  return 0;
885  while (b < end) {
886  int inc = ff_subtitles_next_line(b);
887  if (!inc)
888  break;
889  b += inc;
890  if (b >= end - 4)
891  return 0;
892  if (!memcmp(b, "<svg", 4))
893  return AVPROBE_SCORE_EXTENSION + 1;
894  }
895  return 0;
896 }
897 
898 static int tiff_probe(AVProbeData *p)
899 {
900  const uint8_t *b = p->buf;
901 
902  if (AV_RB32(b) == 0x49492a00 ||
903  AV_RB32(b) == 0x4D4D002a)
904  return AVPROBE_SCORE_EXTENSION + 1;
905  return 0;
906 }
907 
908 static int webp_probe(AVProbeData *p)
909 {
910  const uint8_t *b = p->buf;
911 
912  if (AV_RB32(b) == 0x52494646 &&
913  AV_RB32(b + 8) == 0x57454250)
914  return AVPROBE_SCORE_MAX - 1;
915  return 0;
916 }
917 
918 static int pnm_magic_check(const AVProbeData *p, int magic)
919 {
920  const uint8_t *b = p->buf;
921 
922  return b[0] == 'P' && b[1] == magic + '0';
923 }
924 
925 static inline int pnm_probe(const AVProbeData *p)
926 {
927  const uint8_t *b = p->buf;
928 
929  while (b[2] == '\r')
930  b++;
931  if (b[2] == '\n' && (b[3] == '#' || (b[3] >= '0' && b[3] <= '9')))
932  return AVPROBE_SCORE_EXTENSION + 2;
933  return 0;
934 }
935 
936 static int pbm_probe(AVProbeData *p)
937 {
938  return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0;
939 }
940 
941 static inline int pgmx_probe(AVProbeData *p)
942 {
943  return pnm_magic_check(p, 2) || pnm_magic_check(p, 5) ? pnm_probe(p) : 0;
944 }
945 
946 static int pgm_probe(AVProbeData *p)
947 {
948  int ret = pgmx_probe(p);
949  return ret && !av_match_ext(p->filename, "pgmyuv") ? ret : 0;
950 }
951 
952 static int pgmyuv_probe(AVProbeData *p) // custom FFmpeg format recognized by file extension
953 {
954  int ret = pgmx_probe(p);
955  return ret && av_match_ext(p->filename, "pgmyuv") ? ret : 0;
956 }
957 
958 static int ppm_probe(AVProbeData *p)
959 {
960  return pnm_magic_check(p, 3) || pnm_magic_check(p, 6) ? pnm_probe(p) : 0;
961 }
962 
963 static int pam_probe(AVProbeData *p)
964 {
965  return pnm_magic_check(p, 7) ? pnm_probe(p) : 0;
966 }
967 
968 static int xpm_probe(AVProbeData *p)
969 {
970  const uint8_t *b = p->buf;
971 
972  if (AV_RB64(b) == 0x2f2a2058504d202a && *(b+8) == '/')
973  return AVPROBE_SCORE_MAX - 1;
974  return 0;
975 }
976 
977 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
978 static const AVClass imgname ## _class = {\
979  .class_name = AV_STRINGIFY(imgname) " demuxer",\
980  .item_name = av_default_item_name,\
981  .option = ff_img_options,\
982  .version = LIBAVUTIL_VERSION_INT,\
983 };\
984 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
985  .name = AV_STRINGIFY(imgname) "_pipe",\
986  .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
987  .priv_data_size = sizeof(VideoDemuxData),\
988  .read_probe = imgname ## _probe,\
989  .read_header = ff_img_read_header,\
990  .read_packet = ff_img_read_packet,\
991  .priv_class = & imgname ## _class,\
992  .flags = AVFMT_GENERIC_INDEX, \
993  .raw_codec_id = codecid,\
994 };
995 
Definition: mjpeg.h:93
int img_number
Definition: img2.h:45
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
Bytestream IO Context.
Definition: avio.h:161
static enum AVPixelFormat pix_fmt
int height
Set by a private option.
Definition: img2.h:52
static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: img2dec.c:543
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:336
Definition: mjpeg.h:81
static int pcx_probe(AVProbeData *p)
Definition: img2dec.c:774
static int bmp_probe(AVProbeData *p)
Definition: img2dec.c:624
AVOption.
Definition: opt.h:246
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition: utils.c:2038
#define OFFSET(x)
Definition: img2dec.c:563
Definition: mjpeg.h:71
Definition: mjpeg.h:111
Definition: mjpeg.h:73
static int qdraw_probe(AVProbeData *p)
Definition: img2dec.c:795
const char * fmt
Definition: avisynth_c.h:769
Definition: mjpeg.h:40
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Definition: mjpeg.h:42
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * filename
Definition: avformat.h:449
int64_t pos
byte position in stream, -1 if unknown
Definition: avcodec.h:1450
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **buf, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file...
Definition: aviobuf.c:1111
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:4820
static int psd_probe(AVProbeData *p)
Definition: img2dec.c:829
int64_t pos
Definition: avformat.h:803
AVInputFormat ff_image2_demuxer
char path[1024]
Definition: img2.h:50
static int pgm_probe(AVProbeData *p)
Definition: img2dec.c:946
static int j2k_probe(AVProbeData *p)
Definition: img2dec.c:680
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static int img_read_close(struct AVFormatContext *s1)
Definition: img2dec.c:532
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3884
int num
Numerator.
Definition: rational.h:59
int size
Definition: avcodec.h:1431
const char * b
Definition: vf_curves.c:113
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
#define AVIO_FLAG_READ
read-only
Definition: avio.h:654
#define AVPROBE_PADDING_SIZE
extra allocated bytes at the end of the probe buffer
Definition: avformat.h:462
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:1102
int start_number_range
Definition: img2.h:61
Definition: img2.h:37
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:331
AVInputFormat * av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
Definition: format.c:128
static AVPacket pkt
int ctx_flags
Flags signalling stream properties.
Definition: avformat.h:1391
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:87
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:87
MJPEG encoder and decoder.
static int png_probe(AVProbeData *p)
Definition: img2dec.c:820
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3876
int img_count
Definition: img2.h:47
char * pixel_format
Set by a private option.
Definition: img2.h:51
#define IMAGEAUTO_DEMUXER(imgname, codecid)
Definition: img2dec.c:977
Format I/O context.
Definition: avformat.h:1342
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url...
Definition: avio.c:480
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
Definition: mjpeg.h:72
uint8_t
static int dds_probe(AVProbeData *p)
Definition: img2dec.c:642
int width
Video only.
Definition: avcodec.h:3950
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1286
AVOptions.
int pattern_type
PatternType.
Definition: img2.h:55
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
Definition: avformat.h:661
static int pictor_probe(AVProbeData *p)
Definition: img2dec.c:811
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
enum AVStreamParseType need_parsing
Definition: avformat.h:1091
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition: utils.c:5608
Definition: mjpeg.h:46
Definition: mjpeg.h:113
int ff_img_read_header(AVFormatContext *s1)
Definition: img2dec.c:180
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4450
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:87
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1410
Definition: mjpeg.h:86
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1473
uint8_t * data
Definition: avcodec.h:1430
int(* read_header)(struct AVFormatContext *)
Read the format header and initialize the AVFormatContext structure.
Definition: avformat.h:712
static int img_read_probe(AVProbeData *p)
Definition: img2dec.c:161
static int flags
Definition: log.c:55
#define AVERROR_EOF
End of file.
Definition: error.h:55
static int webp_probe(AVProbeData *p)
Definition: img2dec.c:908
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
Definition: format.c:38
const AVOption ff_img_options[]
Definition: img2dec.c:565
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:557
static const uint8_t header[24]
Definition: sdr2.c:67
Definition: mjpeg.h:87
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1526
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:648
static int exr_probe(AVProbeData *p)
Definition: img2dec.c:671
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1462
static int is_glob(const char *path)
Definition: img2dec.c:78
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:86
#define AVINDEX_KEYFRAME
Definition: avformat.h:810
int64_t pts
Definition: img2.h:46
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:2147
int(* read_probe)(AVProbeData *)
Tell if a given file has a chance of being parsed as this format.
Definition: avformat.h:705
Definition: mjpeg.h:89
static const int sizes[][2]
Definition: img2dec.c:51
int loop
Definition: img2.h:54
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
char * url
input or output URL.
Definition: avformat.h:1438
static int xpm_probe(AVProbeData *p)
Definition: img2dec.c:968
static int pgmyuv_probe(AVProbeData *p)
Definition: img2dec.c:952
int ts_from_file
Definition: img2.h:63
static int svg_probe(AVProbeData *p)
Definition: img2dec.c:878
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3880
uint16_t width
Definition: gdv.c:47
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:83
#define fail()
Definition: checkasm.h:116
Definition: mjpeg.h:39
Definition: mjpeg.h:70
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1436
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:451
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:450
Definition: mjpeg.h:79
Definition: mjpeg.h:80
static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index, const char *path, int start_index, int start_index_range)
Get index range of image files matched by path.
Definition: img2dec.c:108
static int jpeg_probe(AVProbeData *p)
Definition: img2dec.c:690
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1532
Definition: mjpeg.h:44
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:213
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
int is_pipe
Definition: img2.h:48
uint8_t w
Definition: llviddspenc.c:38
Definition: mjpeg.h:91
Definition: mjpeg.h:41
int width
Definition: img2.h:52
Definition: img2.h:35
static int sgi_probe(AVProbeData *p)
Definition: img2dec.c:857
#define AVFMT_FLAG_CUSTOM_IO
The caller has supplied a custom AVIOContext, don't avio_close() it.
Definition: avformat.h:1481
Definition: mjpeg.h:83
static struct @271 state
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:509
int start_number
Definition: img2.h:60
#define FF_ARRAY_ELEMS(a)
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Definition: utils.c:4695
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:530
#define PROBE_BUF_MIN
size of probe buffer, for guessing file type from file contents
Definition: internal.h:33
Stream structure.
Definition: avformat.h:873
#define DEC
Definition: img2dec.c:564
int frame_size
Definition: img2.h:62
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
Definition: mjpeg.h:88
int frame_size
Definition: mxfenc.c:1947
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:251
AVInputFormat ff_image2pipe_demuxer
AVIOContext * pb
I/O context.
Definition: avformat.h:1384
static int loop
Definition: ffplay.c:336
int split_planes
use independent file for each Y, U, V plane
Definition: img2.h:49
static int pbm_probe(AVProbeData *p)
Definition: img2dec.c:936
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:592
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
Definition: utils.c:327
int(* read_packet)(struct AVFormatContext *, AVPacket *pkt)
Read one packet and put it in 'pkt'.
Definition: avformat.h:723
void * buf
Definition: avisynth_c.h:690
Definition: mjpeg.h:84
Describe the class of an AVClass context structure.
Definition: log.h:67
int index
Definition: gxfenc.c:89
static int infer_size(int *width_ptr, int *height_ptr, int size)
Definition: img2dec.c:63
offset must point to AVRational
Definition: opt.h:236
Definition: mjpeg.h:45
#define s1
Definition: regdef.h:38
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:458
offset must point to two consecutive integers
Definition: opt.h:233
This structure contains the data a format has to probe a file.
Definition: avformat.h:448
#define AV_RN32(p)
Definition: intreadwrite.h:364
misc parsing utilities
static int pnm_probe(const AVProbeData *p)
Definition: img2dec.c:925
static int ppm_probe(AVProbeData *p)
Definition: img2dec.c:958
int img_last
Definition: img2.h:44
static int sunrast_probe(AVProbeData *p)
Definition: img2dec.c:869
int raw_codec_id
Raw demuxers store their codec ID here.
Definition: avformat.h:693
Definition: mjpeg.h:47
static av_always_inline int ff_subtitles_next_line(const char *ptr)
Get the number of characters to increment to jump to the next line, or to the end of the string...
Definition: subtitles.h:187
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:922
static int dpx_probe(AVProbeData *p)
Definition: img2dec.c:653
Definition: mjpeg.h:94
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:460
static int tiff_probe(AVProbeData *p)
Definition: img2dec.c:898
full parsing and repack
Definition: avformat.h:793
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
Definition: bytestream.h:87
Main libavformat public API header.
if(ret< 0)
Definition: vf_mcdeint.c:279
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:465
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
Definition: avformat.h:912
Definition: mjpeg.h:90
static double c[64]
int den
Denominator.
Definition: rational.h:60
Definition: mjpeg.h:92
struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1354
enum AVCodecID ff_guess_image2_codec(const char *filename)
Definition: img2.c:102
#define av_free(p)
Definition: mjpeg.h:85
AVRational framerate
Set by a private option.
Definition: img2.h:53
struct AVCodecParserContext * parser
Definition: avformat.h:1092
void * priv_data
Format private data.
Definition: avformat.h:1370
static int pam_probe(AVProbeData *p)
Definition: img2dec.c:963
static int jpegls_probe(AVProbeData *p)
Definition: img2dec.c:765
int use_glob
Definition: img2.h:56
static int pgmx_probe(AVProbeData *p)
Definition: img2dec.c:941
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:647
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1020
Definition: mjpeg.h:82
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:358
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2291
static int pnm_magic_check(const AVProbeData *p, int magic)
Definition: img2dec.c:918
int stream_index
Definition: avcodec.h:1432
int img_first
Definition: img2.h:43
#define MKTAG(a, b, c, d)
Definition: common.h:366
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:1922
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:87
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1407
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1423
int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: img2dec.c:374