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;
178 int first_index, last_index;
209 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
210 av_log(s1,
AV_LOG_ERROR,
"POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
228 char *p = s->
path, *q, *dup;
232 "use pattern_type 'glob' instead\n");
237 if ((p - s->
path) >= (
sizeof(s->
path) - 2))
239 if (*q ==
'%' && strspn(q + 1,
"%*?[]{}"))
241 else if (strspn(q,
"\\*?[]{}"))
248 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
253 last_index = s->globstate.gl_pathc - 1;
261 "Could find no file with path '%s' and index in the range %d-%d\n",
268 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
273 last_index = s->globstate.gl_pathc - 1;
277 "Pattern type 'glob' was selected but globbing "
278 "is not supported by this libavformat build\n");
283 "Unknown value '%d' for pattern_type option\n", s->
pattern_type);
292 st->
duration = last_index - first_index + 1;
306 const char *str = strrchr(s->
path,
'.');
310 int probe_buffer_size = 2048;
318 probe_buffer_size =
avio_read(s1->
pb, probe_buffer, probe_buffer_size);
319 if (probe_buffer_size < 0) {
321 return probe_buffer_size;
325 pd.
buf = probe_buffer;
359 char filename_bytes[1024];
360 char *filename = filename_bytes;
362 int size[3] = { 0 },
ret[3] = { 0 };
375 filename = s->globstate.gl_pathv[s->
img_number];
383 for (i = 0; i < 3; i++) {
396 filename[strlen(filename) - 1] =
'U' + i;
409 memset(header + ret, 0,
sizeof(header) - ret);
440 struct stat img_stat;
441 if (stat(filename, &img_stat))
443 pkt->
pts = (int64_t)img_stat.st_mtime;
444 #
if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
446 pkt->
pts = 1000000000*pkt->
pts + img_stat.st_mtim.tv_nsec;
454 for (i = 0; i < 3; i++) {
464 if (
ret[0] <= 0 ||
ret[1] < 0 ||
ret[2] < 0) {
480 globfree(&s->globstate);
506 #define OFFSET(x) offsetof(VideoDemuxData, x)
507 #define DEC AV_OPT_FLAG_DECODING_PARAM
512 {
"pattern_type",
"set pattern type",
OFFSET(pattern_type),
AV_OPT_TYPE_INT, {.i64=PT_GLOB_SEQUENCE}, 0, INT_MAX,
DEC,
"pattern_type"},
513 {
"glob_sequence",
"select glob/sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
514 {
"glob",
"select glob pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
515 {
"sequence",
"select sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
518 {
"start_number",
"set first number in the sequence",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC },
519 {
"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 },
522 {
"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" },
529 #if CONFIG_IMAGE2_DEMUXER
530 static const AVClass img2_class = {
546 .priv_class = &img2_class,
549 #if CONFIG_IMAGE2PIPE_DEMUXER
550 static const AVClass img2pipe_class = {
557 .
name =
"image2pipe",
562 .priv_class = &img2pipe_class,
575 if (ihsize < 12 || ihsize > 255)
608 if (
AV_RB64(b) == 0x0000000c6a502020 ||
636 if (
AV_RB64(b) == 0x89504e470d0a1a0a)
647 (b[3] & ~3) == 0 && b[3] &&
666 if (
AV_RB32(b) == 0x49492a00 ||
676 if (
AV_RB32(b) == 0x52494646 &&
682 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
683 static const AVClass imgname ## _class = {\
684 .class_name = AV_STRINGIFY(imgname) " demuxer",\
685 .item_name = av_default_item_name,\
686 .option = ff_img_options,\
687 .version = LIBAVUTIL_VERSION_INT,\
689 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
690 .name = AV_STRINGIFY(imgname) "_pipe",\
691 .long_name = NULL_IF_CONFIG_SMALL("piped " AV_STRINGIFY(imgname) " sequence"),\
692 .priv_data_size = sizeof(VideoDemuxData),\
693 .read_probe = imgname ## _probe,\
694 .read_header = ff_img_read_header,\
695 .read_packet = ff_img_read_packet,\
696 .priv_class = & imgname ## _class,\
697 .raw_codec_id = codecid,\