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