37 #define GLOB_NOMAGIC 0
59 enum { PT_GLOB_SEQUENCE, PT_GLOB, PT_SEQUENCE } pattern_type;
88 *width_ptr =
sizes[i][0];
89 *height_ptr =
sizes[i][1];
101 const char *p = path;
103 while (p = strchr(p,
'%')) {
108 if (span = strspn(p,
"*?[]{}"))
128 const char *path,
int start_index,
int start_index_range)
131 int range, last_index, range1, first_index;
134 for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
145 if (first_index == start_index + start_index_range)
149 last_index = first_index;
158 last_index + range1) < 0)
164 if (range >= (1 << 30))
172 *pfirst_index = first_index;
173 *plast_index = last_index;
198 int first_index, last_index;
242 char *p = s->
path, *q, *dup;
246 "use pattern_type 'glob' instead\n");
251 if ((p - s->
path) >= (
sizeof(s->
path) - 2))
253 if (*q ==
'%' && strspn(q + 1,
"%*?[]{}"))
255 else if (strspn(q,
"\\*?[]{}"))
262 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
267 last_index = s->globstate.gl_pathc - 1;
275 "Could find no file with path '%s' and index in the range %d-%d\n",
282 gerr = glob(s->
path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate);
287 last_index = s->globstate.gl_pathc - 1;
291 "Pattern type 'glob' was selected but globbing "
292 "is not supported by this libavformat build\n");
297 "Unknown value '%d' for pattern_type option\n", s->
pattern_type);
306 st->
duration = last_index - first_index + 1;
317 const char *str = strrchr(s->
path,
'.');
334 char filename_bytes[1024];
335 char *filename = filename_bytes;
337 int size[3] = { 0 },
ret[3] = { 0 };
350 filename = s->globstate.gl_pathv[s->
img_number];
358 for (i = 0; i < 3; i++) {
371 filename[strlen(filename) - 1] =
'U' + i;
392 struct stat img_stat;
393 if (stat(filename, &img_stat))
395 pkt->
pts = (int64_t)img_stat.st_mtime;
402 for (i = 0; i < 3; i++) {
412 if (
ret[0] <= 0 ||
ret[1] < 0 ||
ret[2] < 0) {
428 globfree(&s->globstate);
454 #define OFFSET(x) offsetof(VideoDemuxData, x)
455 #define DEC AV_OPT_FLAG_DECODING_PARAM
460 {
"pattern_type",
"set pattern type",
OFFSET(pattern_type),
AV_OPT_TYPE_INT, {.i64=PT_GLOB_SEQUENCE}, 0, INT_MAX,
DEC,
"pattern_type"},
461 {
"glob_sequence",
"select glob/sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB_SEQUENCE}, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
462 {
"glob",
"select glob pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_GLOB }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
463 {
"sequence",
"select sequence pattern type", 0,
AV_OPT_TYPE_CONST, {.i64=PT_SEQUENCE }, INT_MIN, INT_MAX,
DEC,
"pattern_type" },
466 {
"start_number",
"set first number in the sequence",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC },
467 {
"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 },
470 {
"ts_from_file",
"set frame timestamp from file's one",
OFFSET(ts_from_file),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1,
DEC },
474 #if CONFIG_IMAGE2_DEMUXER
475 static const AVClass img2_class = {
491 .priv_class = &img2_class,
494 #if CONFIG_IMAGE2PIPE_DEMUXER
495 static const AVClass img2pipe_class = {
502 .
name =
"image2pipe",
507 .priv_class = &img2pipe_class,