提交 e9e87822 编写于 作者: M Michael Niedermayer

avformat/img2dec: Skip checking the input files existence if it has already been opened

Avoids a unneeded open
Fixes part of Ticket4849
Signed-off-by: NMichael Niedermayer <michael@niedermayer.cc>
上级 f16e4a08
...@@ -103,7 +103,7 @@ static int is_glob(const char *path) ...@@ -103,7 +103,7 @@ static int is_glob(const char *path)
* @param start_index minimum accepted value for the first index in the range * @param start_index minimum accepted value for the first index in the range
* @return -1 if no image file could be found * @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) const char *path, int start_index, int start_index_range)
{ {
char buf[1024]; char buf[1024];
...@@ -114,7 +114,7 @@ static int find_image_range(int *pfirst_index, int *plast_index, ...@@ -114,7 +114,7 @@ static int find_image_range(int *pfirst_index, int *plast_index,
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) { if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
*pfirst_index = *pfirst_index =
*plast_index = 1; *plast_index = 1;
if (avio_check(buf, AVIO_FLAG_READ) > 0) if (pb || avio_check(buf, AVIO_FLAG_READ) > 0)
return 0; return 0;
return -1; return -1;
} }
...@@ -260,7 +260,7 @@ int ff_img_read_header(AVFormatContext *s1) ...@@ -260,7 +260,7 @@ int ff_img_read_header(AVFormatContext *s1)
} }
} }
if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { 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) { s->start_number, s->start_number_range) < 0) {
av_log(s1, AV_LOG_ERROR, av_log(s1, AV_LOG_ERROR,
"Could find no file with path '%s' and index in the range %d-%d\n", "Could find no file with path '%s' and index in the range %d-%d\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册