40 #define GLOB_NOMAGIC 0
66 *width_ptr =
sizes[i][0];
67 *height_ptr =
sizes[i][1];
81 while (p = strchr(p,
'%')) {
86 if (span = strspn(p,
"*?[]{}"))
106 const char *path,
int start_index,
int start_index_range)
109 int range, last_index, range1, first_index;
112 for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
123 if (first_index == start_index + start_index_range)
127 last_index = first_index;
136 last_index + range1) < 0)
142 if (range >= (1 << 30))
150 *pfirst_index = first_index;
151 *plast_index = last_index;
180 int first_index, last_index;
211 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
212 av_log(s1,
AV_LOG_ERROR,
"POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
230 char *p = s->
path, *q, *dup;
234 "use pattern_type 'glob' instead\n");
239 if ((p - s->
path) >= (
sizeof(s->
path) - 2))
241 if (*q ==
'%' && strspn(q + 1,
"%*?[]{}"))
243 else if (strspn(q,
"\\*?[]{}"))
250 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
255 last_index = s->globstate.gl_pathc - 1;
263 "Could find no file with path '%s' and index in the range %d-%d\n",
270 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
275 last_index = s->globstate.gl_pathc - 1;
279 "Pattern type 'glob' was selected but globbing "
280 "is not supported by this libavformat build\n");
285 "Unknown value '%d' for pattern_type option\n", s->
pattern_type);
294 st->
duration = last_index - first_index + 1;
308 const char *str = strrchr(s->
path,
'.');
312 int probe_buffer_size = 2048;
320 probe_buffer_size =
avio_read(s1->
pb, probe_buffer, probe_buffer_size);
321 if (probe_buffer_size < 0) {
323 return probe_buffer_size;
327 pd.
buf = probe_buffer;
361 char filename_bytes[1024];
362 char *filename = filename_bytes;
364 int size[3] = { 0 },
ret[3] = { 0 };
377 filename = s->globstate.gl_pathv[s->
img_number];
385 for (i = 0; i < 3; i++) {
398 filename[strlen(filename) - 1] =
'U' + i;
411 memset(header + ret, 0,
sizeof(header) - ret);
445 struct stat img_stat;
446 if (stat(filename, &img_stat))
448 pkt->
pts = (int64_t)img_stat.st_mtime;
449 #
if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
451 pkt->
pts = 1000000000*pkt->
pts + img_stat.st_mtim.tv_nsec;
462 for (i = 0; i < 3; i++) {
478 if (
ret[0] <= 0 ||
ret[1] < 0 ||
ret[2] < 0) {
482 }
else if (
ret[1] < 0) {
484 }
else if (
ret[2] < 0)
500 globfree(&s->globstate);
526 #define OFFSET(x) offsetof(VideoDemuxData, x)
527 #define DEC AV_OPT_FLAG_DECODING_PARAM
532 {
"pattern_type",
"set pattern type",
OFFSET(pattern_type),
AV_OPT_TYPE_INT, {.i64=PT_GLOB_SEQUENCE}, 0, INT_MAX,
DEC,
"pattern_type"},
533 {
"glob_sequence",
"select glob/sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
534 {
"glob",
"select glob pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
535 {
"sequence",
"select sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
538 {
"start_number",
"set first number in the sequence",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC },
539 {
"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 },
542 {
"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" },
549 #if CONFIG_IMAGE2_DEMUXER
550 static const AVClass img2_class = {
566 .priv_class = &img2_class,
569 #if CONFIG_IMAGE2PIPE_DEMUXER
570 static const AVClass img2pipe_class = {
577 .
name =
"image2pipe",
582 .priv_class = &img2pipe_class,
595 if (ihsize < 12 || ihsize > 255)
628 if (
AV_RB64(b) == 0x0000000c6a502020 ||
644 for (i = 0; i < p->
buf_size - 2; i++) {
674 if ( (c >= 0x02 && c <= 0xBF)
707 if (
AV_RB64(b) == 0x89504e470d0a1a0a)
718 (b[3] & ~3) == 0 && b[3] &&
737 if (
AV_RB32(b) == 0x49492a00 ||
747 if (
AV_RB32(b) == 0x52494646 &&
753 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
754 static const AVClass imgname ## _class = {\
755 .class_name = AV_STRINGIFY(imgname) " demuxer",\
756 .item_name = av_default_item_name,\
757 .option = ff_img_options,\
758 .version = LIBAVUTIL_VERSION_INT,\
760 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
761 .name = AV_STRINGIFY(imgname) "_pipe",\
762 .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
763 .priv_data_size = sizeof(VideoDemuxData),\
764 .read_probe = imgname ## _probe,\
765 .read_header = ff_img_read_header,\
766 .read_packet = ff_img_read_packet,\
767 .priv_class = & imgname ## _class,\
768 .flags = AVFMT_GENERIC_INDEX, \
769 .raw_codec_id = codecid,\