68 static int cmp(
void *key,
const void *node)
70 return (*(int64_t *) key) - ((
const CacheEntry *) node)->logical_pos;
102 pos = lseek(c->
fd, 0, SEEK_END);
110 ret = write(c->
fd, buf, size);
129 if (!entry || !node) {
138 if (entry_ret && entry_ret != entry) {
169 if (in_block_pos < entry->size) {
170 int64_t physical_target = entry->
physical_pos + in_block_pos;
173 r = lseek(c->
fd, physical_target, SEEK_SET);
179 r = read(c->
fd, buf,
FFMIN(size, entry->
size - in_block_pos));
203 if (r == 0 && size>0) {
238 if (whence == SEEK_CUR) {
247 if (whence == SEEK_SET && pos >= 0 && pos < c->
end) {
255 if ((whence == SEEK_SET && pos >= c->
logical_pos ||
256 whence == SEEK_END && pos <= 0) && ret < 0) {
260 while (c->
logical_pos < pos || whence == SEEK_END) {
261 int size =
sizeof(tmp);
262 if (whence == SEEK_SET)
265 if (ret == 0 && whence == SEEK_END) {
289 av_log(h,
AV_LOG_INFO,
"Statistics, cache hits:%"PRId64
" cache misses:%"PRId64
"\n",
299 #define OFFSET(x) offsetof(Context, x)
300 #define D AV_OPT_FLAG_DECODING_PARAM
303 {
"read_ahead_limit",
"Amount in bytes that may be read ahead when seeking isn't supported, -1 for unlimited",
OFFSET(read_ahead_limit),
AV_OPT_TYPE_INT, { .i64 = 65536 }, -1, INT_MAX,
D },
320 .priv_data_size =
sizeof(
Context),
321 .priv_data_class = &cache_context_class,