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