* @param start_index minimum accepted value for the first index in the range
* @return -1 if no image file could be found
*/
-static int find_image_range(int *pfirst_index, int *plast_index,
+static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index,
const char *path, int start_index, int start_index_range)
{
char buf[1024];
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
*pfirst_index =
*plast_index = 1;
- if (avio_check(buf, AVIO_FLAG_READ) > 0)
+ if (pb || avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
}
}
if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) {
- if (find_image_range(&first_index, &last_index, s->path,
+ if (find_image_range(s1->pb, &first_index, &last_index, s->path,
s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR,
"Could find no file with path '%s' and index in the range %d-%d\n",
return AVERROR(EIO);
}
for (i = 0; i < 3; i++) {
- if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
+ if (s1->pb &&
+ !strcmp(filename_bytes, s->path) &&
+ !s->loop &&
+ !s->split_planes) {
+ f[i] = s1->pb;
+ } else if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
&s1->interrupt_callback, NULL) < 0) {
if (i >= 1)
break;
ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]);
}
}
- if (!s->is_pipe)
+ if (!s->is_pipe && f[i] != s1->pb)
avio_closep(&f[i]);
if (ret[i] > 0)
pkt->size += ret[i];
fail:
if (!s->is_pipe) {
for (i = 0; i < 3; i++) {
- avio_closep(&f[i]);
+ if (f[i] != s1->pb)
+ avio_closep(&f[i]);
}
}
return res;