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;
176 int first_index, last_index;
207 #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
208 av_log(s1,
AV_LOG_ERROR,
"POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n");
226 char *p = s->
path, *q, *dup;
230 "use pattern_type 'glob' instead\n");
235 if ((p - s->
path) >= (
sizeof(s->
path) - 2))
237 if (*q ==
'%' && strspn(q + 1,
"%*?[]{}"))
239 else if (strspn(q,
"\\*?[]{}"))
246 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
251 last_index = s->globstate.gl_pathc - 1;
259 "Could find no file with path '%s' and index in the range %d-%d\n",
266 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
271 last_index = s->globstate.gl_pathc - 1;
275 "Pattern type 'glob' was selected but globbing "
276 "is not supported by this libavformat build\n");
281 "Unknown value '%d' for pattern_type option\n", s->
pattern_type);
290 st->
duration = last_index - first_index + 1;
304 const char *str = strrchr(s->
path,
'.');
308 int probe_buffer_size = 2048;
316 probe_buffer_size =
avio_read(s1->
pb, probe_buffer, probe_buffer_size);
317 if (probe_buffer_size < 0) {
319 return probe_buffer_size;
323 pd.
buf = probe_buffer;
357 char filename_bytes[1024];
358 char *filename = filename_bytes;
360 int size[3] = { 0 },
ret[3] = { 0 };
373 filename = s->globstate.gl_pathv[s->
img_number];
381 for (i = 0; i < 3; i++) {
394 filename[strlen(filename) - 1] =
'U' + i;
407 memset(header + ret, 0,
sizeof(header) - ret);
438 struct stat img_stat;
439 if (stat(filename, &img_stat))
441 pkt->
pts = (int64_t)img_stat.st_mtime;
442 #
if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
444 pkt->
pts = 1000000000*pkt->
pts + img_stat.st_mtim.tv_nsec;
452 for (i = 0; i < 3; i++) {
462 if (
ret[0] <= 0 ||
ret[1] < 0 ||
ret[2] < 0) {
478 globfree(&s->globstate);
504 #define OFFSET(x) offsetof(VideoDemuxData, x)
505 #define DEC AV_OPT_FLAG_DECODING_PARAM
510 {
"pattern_type",
"set pattern type",
OFFSET(pattern_type),
AV_OPT_TYPE_INT, {.i64=PT_GLOB_SEQUENCE}, 0, INT_MAX,
DEC,
"pattern_type"},
511 {
"glob_sequence",
"select glob/sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
512 {
"glob",
"select glob pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
513 {
"sequence",
"select sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
516 {
"start_number",
"set first number in the sequence",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC },
517 {
"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 },
520 {
"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" },
527 #if CONFIG_IMAGE2_DEMUXER
528 static const AVClass img2_class = {
544 .priv_class = &img2_class,
547 #if CONFIG_IMAGE2PIPE_DEMUXER
548 static const AVClass img2pipe_class = {
555 .
name =
"image2pipe",
560 .priv_class = &img2pipe_class,
573 if (ihsize < 12 || ihsize > 255)
606 if (
AV_RB64(b) == 0x0000000c6a502020 ||
625 if (
AV_RB64(b) == 0x89504e470d0a1a0a)
636 (b[3] & ~3) == 0 && b[3] &&
660 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
661 static const AVClass imgname ## _class = {\
662 .class_name = AV_STRINGIFY(imgname) " demuxer",\
663 .item_name = av_default_item_name,\
665 .version = LIBAVUTIL_VERSION_INT,\
667 AVInputFormat ff_image_ ## imgname ## _pipe_demuxer = {\
668 .name = AV_STRINGIFY(imgname) "_pipe",\
669 .priv_data_size = sizeof(VideoDemuxData),\
670 .read_probe = imgname ## _probe,\
671 .read_header = ff_img_read_header,\
672 .read_packet = ff_img_read_packet,\
673 .priv_class = & imgname ## _class,\
674 .raw_codec_id = codecid,\