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 "libavcodec/xwd.h"
38 #include "subtitles.h"
39 
40 #if HAVE_GLOB
41 /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
42  are non-posix glibc/bsd extensions. */
43 #ifndef GLOB_NOMAGIC
44 #define GLOB_NOMAGIC 0
45 #endif
46 #ifndef GLOB_BRACE
47 #define GLOB_BRACE 0
48 #endif
49 
50 #endif /* HAVE_GLOB */
51 
52 static const int sizes[][2] = {
53  { 640, 480 },
54  { 720, 480 },
55  { 720, 576 },
56  { 352, 288 },
57  { 352, 240 },
58  { 160, 128 },
59  { 512, 384 },
60  { 640, 352 },
61  { 640, 240 },
62 };
63 
64 static int infer_size(int *width_ptr, int *height_ptr, int size)
65 {
66  int i;
67 
68  for (i = 0; i < FF_ARRAY_ELEMS(sizes); i++) {
69  if ((sizes[i][0] * sizes[i][1]) == size) {
70  *width_ptr = sizes[i][0];
71  *height_ptr = sizes[i][1];
72  return 0;
73  }
74  }
75 
76  return -1;
77 }
78 
79 static int is_glob(const char *path)
80 {
81 #if HAVE_GLOB
82  size_t span = 0;
83  const char *p = path;
84 
85  while (p = strchr(p, '%')) {
86  if (*(++p) == '%') {
87  ++p;
88  continue;
89  }
90  if (span = strspn(p, "*?[]{}"))
91  break;
92  }
93  /* Did we hit a glob char or get to the end? */
94  return span != 0;
95 #else
96  return 0;
97 #endif
98 }
99 
100 /**
101  * Get index range of image files matched by path.
102  *
103  * @param pfirst_index pointer to index updated with the first number in the range
104  * @param plast_index pointer to index updated with the last number in the range
105  * @param path path which has to be matched by the image files in the range
106  * @param start_index minimum accepted value for the first index in the range
107  * @return -1 if no image file could be found
108  */
109 static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index,
110  const char *path, int start_index, int start_index_range)
111 {
112  char buf[1024];
113  int range, last_index, range1, first_index;
114 
115  /* find the first image */
116  for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
117  if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
118  *pfirst_index =
119  *plast_index = 1;
120  if (pb || avio_check(buf, AVIO_FLAG_READ) > 0)
121  return 0;
122  return -1;
123  }
124  if (avio_check(buf, AVIO_FLAG_READ) > 0)
125  break;
126  }
127  if (first_index == start_index + start_index_range)
128  goto fail;
129 
130  /* find the last image */
131  last_index = first_index;
132  for (;;) {
133  range = 0;
134  for (;;) {
135  if (!range)
136  range1 = 1;
137  else
138  range1 = 2 * range;
139  if (av_get_frame_filename(buf, sizeof(buf), path,
140  last_index + range1) < 0)
141  goto fail;
142  if (avio_check(buf, AVIO_FLAG_READ) <= 0)
143  break;
144  range = range1;
145  /* just in case... */
146  if (range >= (1 << 30))
147  goto fail;
148  }
149  /* we are sure than image last_index + range exists */
150  if (!range)
151  break;
152  last_index += range;
153  }
154  *pfirst_index = first_index;
155  *plast_index = last_index;
156  return 0;
157 
158 fail:
159  return -1;
160 }
161 
163 {
164  if (p->filename && ff_guess_image2_codec(p->filename)) {
166  return AVPROBE_SCORE_MAX;
167  else if (is_glob(p->filename))
168  return AVPROBE_SCORE_MAX;
169  else if (p->filename[strcspn(p->filename, "*?{")]) // probably PT_GLOB
170  return AVPROBE_SCORE_EXTENSION + 2; // score chosen to be a tad above the image pipes
171  else if (p->buf_size == 0)
172  return 0;
173  else if (av_match_ext(p->filename, "raw") || av_match_ext(p->filename, "gif"))
174  return 5;
175  else
177  }
178  return 0;
179 }
180 
182 {
183  VideoDemuxData *s = s1->priv_data;
184  int first_index = 1, last_index = 1;
185  AVStream *st;
187 
189 
190  st = avformat_new_stream(s1, NULL);
191  if (!st) {
192  return AVERROR(ENOMEM);
193  }
194 
195  if (s->pixel_format &&
196  (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) {
197  av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n",
198  s->pixel_format);
199  return AVERROR(EINVAL);
200  }
201 
202  av_strlcpy(s->path, s1->url, sizeof(s->path));
203  s->img_number = 0;
204  s->img_count = 0;
205 
206  /* find format */
207  if (s1->iformat->flags & AVFMT_NOFILE)
208  s->is_pipe = 0;
209  else {
210  s->is_pipe = 1;
212  }
213 
214  if (s->ts_from_file == 2) {
215 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
216  av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
217  return AVERROR(ENOSYS);
218 #endif
219  avpriv_set_pts_info(st, 64, 1, 1000000000);
220  } else if (s->ts_from_file)
221  avpriv_set_pts_info(st, 64, 1, 1);
222  else
224 
225  if (s->width && s->height) {
226  st->codecpar->width = s->width;
227  st->codecpar->height = s->height;
228  }
229 
230  if (!s->is_pipe) {
231  if (s->pattern_type == PT_DEFAULT) {
232  if (s1->pb) {
233  s->pattern_type = PT_NONE;
234  } else
236  }
237 
238  if (s->pattern_type == PT_GLOB_SEQUENCE) {
239  s->use_glob = is_glob(s->path);
240  if (s->use_glob) {
241 #if HAVE_GLOB
242  char *p = s->path, *q, *dup;
243  int gerr;
244 #endif
245 
246  av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: "
247  "use pattern_type 'glob' instead\n");
248 #if HAVE_GLOB
249  dup = q = av_strdup(p);
250  while (*q) {
251  /* Do we have room for the next char and a \ insertion? */
252  if ((p - s->path) >= (sizeof(s->path) - 2))
253  break;
254  if (*q == '%' && strspn(q + 1, "%*?[]{}"))
255  ++q;
256  else if (strspn(q, "\\*?[]{}"))
257  *p++ = '\\';
258  *p++ = *q++;
259  }
260  *p = 0;
261  av_free(dup);
262 
263  gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
264  if (gerr != 0) {
265  return AVERROR(ENOENT);
266  }
267  first_index = 0;
268  last_index = s->globstate.gl_pathc - 1;
269 #endif
270  }
271  }
272  if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) {
273  if (find_image_range(s1->pb, &first_index, &last_index, s->path,
274  s->start_number, s->start_number_range) < 0) {
275  av_log(s1, AV_LOG_ERROR,
276  "Could find no file with path '%s' and index in the range %d-%d\n",
277  s->path, s->start_number, s->start_number + s->start_number_range - 1);
278  return AVERROR(ENOENT);
279  }
280  } else if (s->pattern_type == PT_GLOB) {
281 #if HAVE_GLOB
282  int gerr;
283  gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
284  if (gerr != 0) {
285  return AVERROR(ENOENT);
286  }
287  first_index = 0;
288  last_index = s->globstate.gl_pathc - 1;
289  s->use_glob = 1;
290 #else
291  av_log(s1, AV_LOG_ERROR,
292  "Pattern type 'glob' was selected but globbing "
293  "is not supported by this libavformat build\n");
294  return AVERROR(ENOSYS);
295 #endif
296  } else if (s->pattern_type != PT_GLOB_SEQUENCE && s->pattern_type != PT_NONE) {
297  av_log(s1, AV_LOG_ERROR,
298  "Unknown value '%d' for pattern_type option\n", s->pattern_type);
299  return AVERROR(EINVAL);
300  }
301  s->img_first = first_index;
302  s->img_last = last_index;
303  s->img_number = first_index;
304  /* compute duration */
305  if (!s->ts_from_file) {
306  st->start_time = 0;
307  st->duration = last_index - first_index + 1;
308  }
309  }
310 
311  if (s1->video_codec_id) {
313  st->codecpar->codec_id = s1->video_codec_id;
314  } else if (s1->audio_codec_id) {
316  st->codecpar->codec_id = s1->audio_codec_id;
317  } else if (s1->iformat->raw_codec_id) {
320  } else {
321  const char *str = strrchr(s->path, '.');
322  s->split_planes = str && !av_strcasecmp(str + 1, "y");
324  if (s1->pb) {
325  int probe_buffer_size = 2048;
326  uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE);
327  const AVInputFormat *fmt = NULL;
328  void *fmt_iter = NULL;
329  AVProbeData pd = { 0 };
330 
331  if (!probe_buffer)
332  return AVERROR(ENOMEM);
333 
334  probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size);
335  if (probe_buffer_size < 0) {
336  av_free(probe_buffer);
337  return probe_buffer_size;
338  }
339  memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE);
340 
341  pd.buf = probe_buffer;
342  pd.buf_size = probe_buffer_size;
343  pd.filename = s1->url;
344 
345  while ((fmt = av_demuxer_iterate(&fmt_iter))) {
346  if (fmt->read_header != ff_img_read_header ||
347  !fmt->read_probe ||
348  (fmt->flags & AVFMT_NOFILE) ||
349  !fmt->raw_codec_id)
350  continue;
351  if (fmt->read_probe(&pd) > 0) {
352  st->codecpar->codec_id = fmt->raw_codec_id;
353  break;
354  }
355  }
356  if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
357  avio_seek(s1->pb, 0, SEEK_SET);
358  } else
359  ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
360  }
361  if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
363  if (st->codecpar->codec_id == AV_CODEC_ID_LJPEG)
365  if (st->codecpar->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX
367  }
368  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
369  pix_fmt != AV_PIX_FMT_NONE)
370  st->codecpar->format = pix_fmt;
371 
372  return 0;
373 }
374 
376 {
377  VideoDemuxData *s = s1->priv_data;
378  char filename_bytes[1024];
379  char *filename = filename_bytes;
380  int i, res;
381  int size[3] = { 0 }, ret[3] = { 0 };
382  AVIOContext *f[3] = { NULL };
383  AVCodecParameters *par = s1->streams[0]->codecpar;
384 
385  if (!s->is_pipe) {
386  /* loop over input */
387  if (s->loop && s->img_number > s->img_last) {
388  s->img_number = s->img_first;
389  }
390  if (s->img_number > s->img_last)
391  return AVERROR_EOF;
392  if (s->pattern_type == PT_NONE) {
393  av_strlcpy(filename_bytes, s->path, sizeof(filename_bytes));
394  } else if (s->use_glob) {
395 #if HAVE_GLOB
396  filename = s->globstate.gl_pathv[s->img_number];
397 #endif
398  } else {
399  if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes),
400  s->path,
401  s->img_number) < 0 && s->img_number > 1)
402  return AVERROR(EIO);
403  }
404  for (i = 0; i < 3; i++) {
405  if (s1->pb &&
406  !strcmp(filename_bytes, s->path) &&
407  !s->loop &&
408  !s->split_planes) {
409  f[i] = s1->pb;
410  } else if (s1->io_open(s1, &f[i], filename, AVIO_FLAG_READ, NULL) < 0) {
411  if (i >= 1)
412  break;
413  av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",
414  filename);
415  return AVERROR(EIO);
416  }
417  size[i] = avio_size(f[i]);
418 
419  if (!s->split_planes)
420  break;
421  filename[strlen(filename) - 1] = 'U' + i;
422  }
423 
424  if (par->codec_id == AV_CODEC_ID_NONE) {
425  AVProbeData pd = { 0 };
426  AVInputFormat *ifmt;
428  int ret;
429  int score = 0;
430 
431  ret = avio_read(f[0], header, PROBE_BUF_MIN);
432  if (ret < 0)
433  return ret;
434  memset(header + ret, 0, sizeof(header) - ret);
435  avio_skip(f[0], -ret);
436  pd.buf = header;
437  pd.buf_size = ret;
438  pd.filename = filename;
439 
440  ifmt = av_probe_input_format3(&pd, 1, &score);
441  if (ifmt && ifmt->read_packet == ff_img_read_packet && ifmt->raw_codec_id)
442  par->codec_id = ifmt->raw_codec_id;
443  }
444 
445  if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
446  infer_size(&par->width, &par->height, size[0]);
447  } else {
448  f[0] = s1->pb;
449  if (avio_feof(f[0]) && s->loop && s->is_pipe)
450  avio_seek(f[0], 0, SEEK_SET);
451  if (avio_feof(f[0]))
452  return AVERROR_EOF;
453  if (s->frame_size > 0) {
454  size[0] = s->frame_size;
455  } else if (!s1->streams[0]->parser) {
456  size[0] = avio_size(s1->pb);
457  } else {
458  size[0] = 4096;
459  }
460  }
461 
462  res = av_new_packet(pkt, size[0] + size[1] + size[2]);
463  if (res < 0) {
464  goto fail;
465  }
466  pkt->stream_index = 0;
467  pkt->flags |= AV_PKT_FLAG_KEY;
468  if (s->ts_from_file) {
469  struct stat img_stat;
470  if (stat(filename, &img_stat)) {
471  res = AVERROR(EIO);
472  goto fail;
473  }
474  pkt->pts = (int64_t)img_stat.st_mtime;
475 #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
476  if (s->ts_from_file == 2)
477  pkt->pts = 1000000000*pkt->pts + img_stat.st_mtim.tv_nsec;
478 #endif
479  av_add_index_entry(s1->streams[0], s->img_number, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
480  } else if (!s->is_pipe) {
481  pkt->pts = s->pts;
482  }
483 
484  if (s->is_pipe)
485  pkt->pos = avio_tell(f[0]);
486 
487  pkt->size = 0;
488  for (i = 0; i < 3; i++) {
489  if (f[i]) {
490  ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
491  if (s->loop && s->is_pipe && ret[i] == AVERROR_EOF) {
492  if (avio_seek(f[i], 0, SEEK_SET) >= 0) {
493  pkt->pos = 0;
494  ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
495  }
496  }
497  if (!s->is_pipe && f[i] != s1->pb)
498  ff_format_io_close(s1, &f[i]);
499  if (ret[i] > 0)
500  pkt->size += ret[i];
501  }
502  }
503 
504  if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
505  av_packet_unref(pkt);
506  if (ret[0] < 0) {
507  res = ret[0];
508  } else if (ret[1] < 0) {
509  res = ret[1];
510  } else if (ret[2] < 0) {
511  res = ret[2];
512  } else {
513  res = AVERROR_EOF;
514  }
515  goto fail;
516  } else {
517  s->img_count++;
518  s->img_number++;
519  s->pts++;
520  return 0;
521  }
522 
523 fail:
524  if (!s->is_pipe) {
525  for (i = 0; i < 3; i++) {
526  if (f[i] != s1->pb)
527  ff_format_io_close(s1, &f[i]);
528  }
529  }
530  return res;
531 }
532 
533 static int img_read_close(struct AVFormatContext* s1)
534 {
535 #if HAVE_GLOB
536  VideoDemuxData *s = s1->priv_data;
537  if (s->use_glob) {
538  globfree(&s->globstate);
539  }
540 #endif
541  return 0;
542 }
543 
544 static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
545 {
547  AVStream *st = s->streams[0];
548 
549  if (s1->ts_from_file) {
550  int index = av_index_search_timestamp(st, timestamp, flags);
551  if(index < 0)
552  return -1;
553  s1->img_number = st->index_entries[index].pos;
554  return 0;
555  }
556 
557  if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first)
558  return -1;
559  s1->img_number = timestamp%(s1->img_last - s1->img_first + 1) + s1->img_first;
560  s1->pts = timestamp;
561  return 0;
562 }
563 
564 #define OFFSET(x) offsetof(VideoDemuxData, x)
565 #define DEC AV_OPT_FLAG_DECODING_PARAM
567  { "framerate", "set the video framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC },
568  { "loop", "force loop over input file sequence", OFFSET(loop), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC },
569 
570  { "pattern_type", "set pattern type", OFFSET(pattern_type), AV_OPT_TYPE_INT, {.i64=PT_DEFAULT}, 0, INT_MAX, DEC, "pattern_type"},
571  { "glob_sequence","select glob/sequence pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX, DEC, "pattern_type" },
572  { "glob", "select glob pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX, DEC, "pattern_type" },
573  { "sequence", "select sequence pattern type", 0, AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX, DEC, "pattern_type" },
574  { "none", "disable pattern matching", 0, AV_OPT_TYPE_CONST, {.i64=PT_NONE }, INT_MIN, INT_MAX, DEC, "pattern_type" },
575 
576  { "pixel_format", "set video pixel format", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
577  { "start_number", "set first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, DEC },
578  { "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 },
579  { "video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
580  { "frame_size", "force frame size in bytes", OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, DEC },
581  { "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" },
582  { "none", "none", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 2, DEC, "ts_type" },
583  { "sec", "second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 2, DEC, "ts_type" },
584  { "ns", "nano second precision", 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 2, DEC, "ts_type" },
585  { NULL },
586 };
587 
588 #if CONFIG_IMAGE2_DEMUXER
589 static const AVClass img2_class = {
590  .class_name = "image2 demuxer",
591  .item_name = av_default_item_name,
592  .option = ff_img_options,
593  .version = LIBAVUTIL_VERSION_INT,
594 };
596  .name = "image2",
597  .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"),
598  .priv_data_size = sizeof(VideoDemuxData),
604  .flags = AVFMT_NOFILE,
605  .priv_class = &img2_class,
606 };
607 #endif
608 #if CONFIG_IMAGE2PIPE_DEMUXER
609 static const AVClass img2pipe_class = {
610  .class_name = "image2pipe demuxer",
611  .item_name = av_default_item_name,
612  .option = ff_img_options,
613  .version = LIBAVUTIL_VERSION_INT,
614 };
616  .name = "image2pipe",
617  .long_name = NULL_IF_CONFIG_SMALL("piped image2 sequence"),
618  .priv_data_size = sizeof(VideoDemuxData),
621  .priv_class = &img2pipe_class,
622 };
623 #endif
624 
625 static int bmp_probe(AVProbeData *p)
626 {
627  const uint8_t *b = p->buf;
628  int ihsize;
629 
630  if (AV_RB16(b) != 0x424d)
631  return 0;
632 
633  ihsize = AV_RL32(b+14);
634  if (ihsize < 12 || ihsize > 255)
635  return 0;
636 
637  if (!AV_RN32(b + 6)) {
638  return AVPROBE_SCORE_EXTENSION + 1;
639  }
640  return AVPROBE_SCORE_EXTENSION / 4;
641 }
642 
643 static int dds_probe(AVProbeData *p)
644 {
645  const uint8_t *b = p->buf;
646 
647  if ( AV_RB64(b) == 0x444453207c000000
648  && AV_RL32(b + 8)
649  && AV_RL32(b + 12))
650  return AVPROBE_SCORE_MAX - 1;
651  return 0;
652 }
653 
654 static int dpx_probe(AVProbeData *p)
655 {
656  const uint8_t *b = p->buf;
657  int w, h;
658  int is_big = (AV_RN32(b) == AV_RN32("SDPX"));
659 
660  if (p->buf_size < 0x304+8)
661  return 0;
662  w = is_big ? AV_RB32(p->buf + 0x304) : AV_RL32(p->buf + 0x304);
663  h = is_big ? AV_RB32(p->buf + 0x308) : AV_RL32(p->buf + 0x308);
664  if (w <= 0 || h <= 0)
665  return 0;
666 
667  if (is_big || AV_RN32(b) == AV_RN32("XPDS"))
668  return AVPROBE_SCORE_EXTENSION + 1;
669  return 0;
670 }
671 
672 static int exr_probe(AVProbeData *p)
673 {
674  const uint8_t *b = p->buf;
675 
676  if (AV_RL32(b) == 20000630)
677  return AVPROBE_SCORE_EXTENSION + 1;
678  return 0;
679 }
680 
681 static int j2k_probe(AVProbeData *p)
682 {
683  const uint8_t *b = p->buf;
684 
685  if (AV_RB64(b) == 0x0000000c6a502020 ||
686  AV_RB32(b) == 0xff4fff51)
687  return AVPROBE_SCORE_EXTENSION + 1;
688  return 0;
689 }
690 
691 static int jpeg_probe(AVProbeData *p)
692 {
693  const uint8_t *b = p->buf;
694  int i, state = SOI;
695 
696  if (AV_RB16(b) != 0xFFD8 ||
697  AV_RB32(b) == 0xFFD8FFF7)
698  return 0;
699 
700  b += 2;
701  for (i = 0; i < p->buf_size - 3; i++) {
702  int c;
703  if (b[i] != 0xFF)
704  continue;
705  c = b[i + 1];
706  switch (c) {
707  case SOI:
708  return 0;
709  case SOF0:
710  case SOF1:
711  case SOF2:
712  case SOF3:
713  case SOF5:
714  case SOF6:
715  case SOF7:
716  i += AV_RB16(&b[i + 2]) + 1;
717  if (state != SOI)
718  return 0;
719  state = SOF0;
720  break;
721  case SOS:
722  i += AV_RB16(&b[i + 2]) + 1;
723  if (state != SOF0 && state != SOS)
724  return 0;
725  state = SOS;
726  break;
727  case EOI:
728  if (state != SOS)
729  return 0;
730  state = EOI;
731  break;
732  case DQT:
733  case APP0:
734  case APP1:
735  case APP2:
736  case APP3:
737  case APP4:
738  case APP5:
739  case APP6:
740  case APP7:
741  case APP8:
742  case APP9:
743  case APP10:
744  case APP11:
745  case APP12:
746  case APP13:
747  case APP14:
748  case APP15:
749  case COM:
750  i += AV_RB16(&b[i + 2]) + 1;
751  break;
752  default:
753  if ( (c > TEM && c < SOF0)
754  || c == JPG)
755  return 0;
756  }
757  }
758 
759  if (state == EOI)
760  return AVPROBE_SCORE_EXTENSION + 1;
761  if (state == SOS)
762  return AVPROBE_SCORE_EXTENSION / 2;
763  return AVPROBE_SCORE_EXTENSION / 8;
764 }
765 
766 static int jpegls_probe(AVProbeData *p)
767 {
768  const uint8_t *b = p->buf;
769 
770  if (AV_RB32(b) == 0xffd8fff7)
771  return AVPROBE_SCORE_EXTENSION + 1;
772  return 0;
773 }
774 
775 static int pcx_probe(AVProbeData *p)
776 {
777  const uint8_t *b = p->buf;
778 
779  if ( p->buf_size < 128
780  || b[0] != 10
781  || b[1] > 5
782  || b[2] > 1
783  || av_popcount(b[3]) != 1 || b[3] > 8
784  || AV_RL16(&b[4]) > AV_RL16(&b[8])
785  || AV_RL16(&b[6]) > AV_RL16(&b[10])
786  || b[64])
787  return 0;
788  b += 73;
789  while (++b < p->buf + 128)
790  if (*b)
791  return AVPROBE_SCORE_EXTENSION / 4;
792 
793  return AVPROBE_SCORE_EXTENSION + 1;
794 }
795 
796 static int qdraw_probe(AVProbeData *p)
797 {
798  const uint8_t *b = p->buf;
799 
800  if ( p->buf_size >= 528
801  && (AV_RB64(b + 520) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
802  && AV_RB16(b + 520)
803  && AV_RB16(b + 518))
804  return AVPROBE_SCORE_MAX * 3 / 4;
805  if ( (AV_RB64(b + 8) & 0xFFFFFFFFFFFF) == 0x001102ff0c00
806  && AV_RB16(b + 8)
807  && AV_RB16(b + 6))
808  return AVPROBE_SCORE_EXTENSION / 4;
809  return 0;
810 }
811 
812 static int pictor_probe(AVProbeData *p)
813 {
814  const uint8_t *b = p->buf;
815 
816  if (AV_RL16(b) == 0x1234)
817  return AVPROBE_SCORE_EXTENSION / 4;
818  return 0;
819 }
820 
821 static int png_probe(AVProbeData *p)
822 {
823  const uint8_t *b = p->buf;
824 
825  if (AV_RB64(b) == 0x89504e470d0a1a0a)
826  return AVPROBE_SCORE_MAX - 1;
827  return 0;
828 }
829 
830 static int psd_probe(AVProbeData *p)
831 {
832  const uint8_t *b = p->buf;
833  int ret = 0;
834  uint16_t color_mode;
835 
836  if (AV_RL32(b) == MKTAG('8','B','P','S')) {
837  ret += 1;
838  } else {
839  return 0;
840  }
841 
842  if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */
843  ret += 1;
844  } else {
845  return 0;
846  }
847 
848  if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */
849  ret += 1;
850 
851  color_mode = AV_RB16(b+24);
852  if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6))
853  ret += 1;
854 
855  return AVPROBE_SCORE_EXTENSION + ret;
856 }
857 
858 static int sgi_probe(AVProbeData *p)
859 {
860  const uint8_t *b = p->buf;
861 
862  if (AV_RB16(b) == 474 &&
863  (b[2] & ~1) == 0 &&
864  (b[3] & ~3) == 0 && b[3] &&
865  (AV_RB16(b + 4) & ~7) == 0 && AV_RB16(b + 4))
866  return AVPROBE_SCORE_EXTENSION + 1;
867  return 0;
868 }
869 
871 {
872  const uint8_t *b = p->buf;
873 
874  if (AV_RB32(b) == 0x59a66a95)
875  return AVPROBE_SCORE_EXTENSION + 1;
876  return 0;
877 }
878 
879 static int svg_probe(AVProbeData *p)
880 {
881  const uint8_t *b = p->buf;
882  const uint8_t *end = p->buf + p->buf_size;
883 
884  if (memcmp(p->buf, "<?xml", 5))
885  return 0;
886  while (b < end) {
887  int inc = ff_subtitles_next_line(b);
888  if (!inc)
889  break;
890  b += inc;
891  if (b >= end - 4)
892  return 0;
893  if (!memcmp(b, "<svg", 4))
894  return AVPROBE_SCORE_EXTENSION + 1;
895  }
896  return 0;
897 }
898 
899 static int tiff_probe(AVProbeData *p)
900 {
901  const uint8_t *b = p->buf;
902 
903  if (AV_RB32(b) == 0x49492a00 ||
904  AV_RB32(b) == 0x4D4D002a)
905  return AVPROBE_SCORE_EXTENSION + 1;
906  return 0;
907 }
908 
909 static int webp_probe(AVProbeData *p)
910 {
911  const uint8_t *b = p->buf;
912 
913  if (AV_RB32(b) == 0x52494646 &&
914  AV_RB32(b + 8) == 0x57454250)
915  return AVPROBE_SCORE_MAX - 1;
916  return 0;
917 }
918 
919 static int pnm_magic_check(const AVProbeData *p, int magic)
920 {
921  const uint8_t *b = p->buf;
922 
923  return b[0] == 'P' && b[1] == magic + '0';
924 }
925 
926 static inline int pnm_probe(const AVProbeData *p)
927 {
928  const uint8_t *b = p->buf;
929 
930  while (b[2] == '\r')
931  b++;
932  if (b[2] == '\n' && (b[3] == '#' || (b[3] >= '0' && b[3] <= '9')))
933  return AVPROBE_SCORE_EXTENSION + 2;
934  return 0;
935 }
936 
937 static int pbm_probe(AVProbeData *p)
938 {
939  return pnm_magic_check(p, 1) || pnm_magic_check(p, 4) ? pnm_probe(p) : 0;
940 }
941 
942 static inline int pgmx_probe(AVProbeData *p)
943 {
944  return pnm_magic_check(p, 2) || pnm_magic_check(p, 5) ? pnm_probe(p) : 0;
945 }
946 
947 static int pgm_probe(AVProbeData *p)
948 {
949  int ret = pgmx_probe(p);
950  return ret && !av_match_ext(p->filename, "pgmyuv") ? ret : 0;
951 }
952 
953 static int pgmyuv_probe(AVProbeData *p) // custom FFmpeg format recognized by file extension
954 {
955  int ret = pgmx_probe(p);
956  return ret && av_match_ext(p->filename, "pgmyuv") ? ret : 0;
957 }
958 
959 static int ppm_probe(AVProbeData *p)
960 {
961  return pnm_magic_check(p, 3) || pnm_magic_check(p, 6) ? pnm_probe(p) : 0;
962 }
963 
964 static int pam_probe(AVProbeData *p)
965 {
966  return pnm_magic_check(p, 7) ? pnm_probe(p) : 0;
967 }
968 
969 static int xpm_probe(AVProbeData *p)
970 {
971  const uint8_t *b = p->buf;
972 
973  if (AV_RB64(b) == 0x2f2a2058504d202a && *(b+8) == '/')
974  return AVPROBE_SCORE_MAX - 1;
975  return 0;
976 }
977 
978 static int xwd_probe(AVProbeData *p)
979 {
980  const uint8_t *b = p->buf;
981  unsigned width, bpp, bpad, lsize;
982 
983  if ( p->buf_size < XWD_HEADER_SIZE
984  || AV_RB32(b ) < XWD_HEADER_SIZE // header size
985  || AV_RB32(b + 4) != XWD_VERSION // version
986  || AV_RB32(b + 8) != XWD_Z_PIXMAP // format
987  || AV_RB32(b + 12) > 32 || !AV_RB32(b + 12) // depth
988  || AV_RB32(b + 16) == 0 // width
989  || AV_RB32(b + 20) == 0 // height
990  || AV_RB32(b + 28) > 1 // byteorder
991  || AV_RB32(b + 32) & ~56 || av_popcount(AV_RB32(b + 32)) != 1 // bitmap unit
992  || AV_RB32(b + 36) > 1 // bitorder
993  || AV_RB32(b + 40) & ~56 || av_popcount(AV_RB32(b + 40)) != 1 // padding
994  || AV_RB32(b + 44) > 32 || !AV_RB32(b + 44) // bpp
995  || AV_RB32(b + 68) > 256) // colours
996  return 0;
997 
998  width = AV_RB32(b + 16);
999  bpad = AV_RB32(b + 40);
1000  bpp = AV_RB32(b + 44);
1001  lsize = AV_RB32(b + 48);
1002  if (lsize < FFALIGN(width * bpp, bpad) >> 3)
1003  return 0;
1004 
1005  return AVPROBE_SCORE_MAX / 2 + 1;
1006 }
1007 
1008 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
1009 static const AVClass imgname ## _class = {\
1010  .class_name = AV_STRINGIFY(imgname) " demuxer",\
1011  .item_name = av_default_item_name,\
1012  .option = ff_img_options,\
1013  .version = LIBAVUTIL_VERSION_INT,\
1014 };\
1015 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
1016  .name = AV_STRINGIFY(imgname) "_pipe",\
1017  .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
1018  .priv_data_size = sizeof(VideoDemuxData),\
1019  .read_probe = imgname ## _probe,\
1020  .read_header = ff_img_read_header,\
1021  .read_packet = ff_img_read_packet,\
1022  .priv_class = & imgname ## _class,\
1023  .flags = AVFMT_GENERIC_INDEX, \
1024  .raw_codec_id = codecid,\
1025 };
1026 
Definition: mjpeg.h:93
int img_number
Definition: img2.h:45
#define NULL
Definition: coverity.c:32
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:544
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:775
static int bmp_probe(AVProbeData *p)
Definition: img2dec.c:625
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:564
Definition: mjpeg.h:71
Definition: mjpeg.h:111
Definition: mjpeg.h:73
static int qdraw_probe(AVProbeData *p)
Definition: img2dec.c:796
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:1451
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:4849
static int psd_probe(AVProbeData *p)
Definition: img2dec.c:830
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:947
static int j2k_probe(AVProbeData *p)
Definition: img2dec.c:681
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:533
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3885
int num
Numerator.
Definition: rational.h:59
int size
Definition: avcodec.h:1432
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:1103
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:1400
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:821
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3877
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:1008
Format I/O context.
Definition: avformat.h:1351
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:643
int width
Video only.
Definition: avcodec.h:3951
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1295
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:812
#define f(width, name)
Definition: cbs_vp9.c:255
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
enum AVStreamParseType need_parsing
Definition: avformat.h:1092
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
Definition: utils.c:5637
Definition: mjpeg.h:46
Definition: mjpeg.h:113
int ff_img_read_header(AVFormatContext *s1)
Definition: img2dec.c:181
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4456
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:1419
Definition: mjpeg.h:86
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1482
uint8_t * data
Definition: avcodec.h:1431
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:162
#define XWD_HEADER_SIZE
Definition: xwd.h:27
#define AVERROR_EOF
End of file.
Definition: error.h:55
static int webp_probe(AVProbeData *p)
Definition: img2dec.c:909
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:566
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
#define flags(name, subs,...)
Definition: cbs_h2645.c:263
Definition: mjpeg.h:87
#define XWD_VERSION
Definition: xwd.h:26
#define FFALIGN(x, a)
Definition: macros.h:48
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1537
#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:672
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1463
static int is_glob(const char *path)
Definition: img2dec.c:79
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
#define XWD_Z_PIXMAP
Definition: xwd.h:32
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:52
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:1447
static int xpm_probe(AVProbeData *p)
Definition: img2dec.c:969
static int pgmyuv_probe(AVProbeData *p)
Definition: img2dec.c:953
int ts_from_file
Definition: img2.h:63
static int svg_probe(AVProbeData *p)
Definition: img2dec.c:879
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3881
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:117
Definition: mjpeg.h:39
Definition: mjpeg.h:70
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1437
static int xwd_probe(AVProbeData *p)
Definition: img2dec.c:978
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:109
static int jpeg_probe(AVProbeData *p)
Definition: img2dec.c:691
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1543
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
#define s(width, name)
Definition: cbs_vp9.c:257
static int sgi_probe(AVProbeData *p)
Definition: img2dec.c:858
#define AVFMT_FLAG_CUSTOM_IO
The caller has supplied a custom AVIOContext, don't avio_close() it.
Definition: avformat.h:1490
Definition: mjpeg.h:83
const AVInputFormat * av_demuxer_iterate(void **opaque)
Iterate over all registered demuxers.
Definition: allformats.c:511
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:4724
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:874
#define DEC
Definition: img2dec.c:565
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:2117
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:1393
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:937
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:64
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:926
static int ppm_probe(AVProbeData *p)
Definition: img2dec.c:959
int img_last
Definition: img2.h:44
static int sunrast_probe(AVProbeData *p)
Definition: img2dec.c:870
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
static struct @282 state
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:923
static int dpx_probe(AVProbeData *p)
Definition: img2dec.c:654
Definition: mjpeg.h:94
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:460
static int tiff_probe(AVProbeData *p)
Definition: img2dec.c:899
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:913
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:1363
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:1093
void * priv_data
Format private data.
Definition: avformat.h:1379
static int pam_probe(AVProbeData *p)
Definition: img2dec.c:964
static int jpegls_probe(AVProbeData *p)
Definition: img2dec.c:766
int use_glob
Definition: img2.h:56
static int pgmx_probe(AVProbeData *p)
Definition: img2dec.c:942
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:1021
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:2312
static int pnm_magic_check(const AVProbeData *p, int magic)
Definition: img2dec.c:919
int stream_index
Definition: avcodec.h:1433
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:1933
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:1408
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1424
int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: img2dec.c:375