diff options
author | Tomas Härdin <tomas.hardin@codemill.se> | 2010-04-08 09:02:27 +0000 |
---|---|---|
committer | Tomas Härdin <tomas.hardin@codemill.se> | 2010-04-08 09:02:27 +0000 |
commit | 01d91b9be978753803fa6f5e73b17ab9f03a5c7b (patch) | |
tree | 35a484f2b8a8da202fdf2c815f41f8f9d14053d7 /libavformat/utils.c | |
parent | ba659bedb806cb4a1dd375f723a2b0017d6afb33 (diff) | |
download | ffmpeg-01d91b9be978753803fa6f5e73b17ab9f03a5c7b.tar.gz |
Reusing the probe buffer to rewind the ByteIOContext in ff_probe_input_buffer() instead of seeking back to the start of the file. Once exhausted, the size of the buffer is reduced.
Originally committed as revision 22821 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 5f9feec500..aa779ed80d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -516,19 +516,16 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt, } } - av_free(buf); - if (!*fmt) { + av_free(buf); return AVERROR_INVALIDDATA; } - if (url_fseek(*pb, 0, SEEK_SET) < 0) { - url_fclose(*pb); - if (url_fopen(pb, filename, URL_RDONLY) < 0) - return AVERROR(EIO); - } + /* rewind. reuse probe buffer to avoid seeking */ + if ((ret = ff_rewind_with_probe_data(*pb, buf, pd.buf_size)) < 0) + av_free(buf); - return 0; + return ret; } int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, |