projects
/
ffmpeg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ce35518
)
avformat/cache: avoid lseek() on reading from the cache if possible
author
Michael Niedermayer
<michaelni@gmx.at>
Fri, 26 Dec 2014 00:23:54 +0000
(
01:23
+0100)
committer
Michael Niedermayer
<michaelni@gmx.at>
Fri, 26 Dec 2014 00:24:27 +0000
(
01:24
+0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/cache.c
patch
|
blob
|
history
diff --git
a/libavformat/cache.c
b/libavformat/cache.c
index
9a0c4bb
..
f1e623a
100644
(file)
--- a/
libavformat/cache.c
+++ b/
libavformat/cache.c
@@
-156,8
+156,12
@@
static int cache_read(URLContext *h, unsigned char *buf, int size)
av_assert0(entry->logical_pos <= c->logical_pos);
if (in_block_pos < entry->size) {
int64_t physical_target = entry->physical_pos + in_block_pos;
- //FIXME avoid seek if unneeded
- r = lseek(c->fd, physical_target, SEEK_SET);
+
+ if (c->cache_pos != physical_target) {
+ r = lseek(c->fd, physical_target, SEEK_SET);
+ } else
+ r = c->cache_pos;
+
if (r >= 0) {
c->cache_pos = r;
r = read(c->fd, buf, FFMIN(size, entry->size - in_block_pos));