69 static int cmp(
const void *
key,
const void *node)
88 ret = unlink(buffername);
109 pos = lseek(c->
fd, 0, SEEK_END);
117 ret = write(c->
fd, buf, size);
136 if (!entry || !node) {
145 if (entry_ret && entry_ret != entry) {
176 if (in_block_pos < entry->size) {
177 int64_t physical_target = entry->
physical_pos + in_block_pos;
180 r = lseek(c->
fd, physical_target, SEEK_SET);
186 r = read(c->
fd, buf,
FFMIN(size, entry->
size - in_block_pos));
245 if (whence == SEEK_CUR) {
254 if (whence == SEEK_SET && pos >= 0 && pos < c->
end) {
262 if ((whence == SEEK_SET && pos >= c->
logical_pos ||
263 whence == SEEK_END && pos <= 0) && ret < 0) {
267 while (c->
logical_pos < pos || whence == SEEK_END) {
269 if (whence == SEEK_SET)
303 av_log(h,
AV_LOG_INFO,
"Statistics, cache hits:%"PRId64
" cache misses:%"PRId64
"\n",
320 #define OFFSET(x) offsetof(Context, x) 321 #define D AV_OPT_FLAG_DECODING_PARAM 324 {
"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 },
341 .priv_data_size =
sizeof(
Context),
342 .priv_data_class = &cache_context_class,
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
support keeping files support filling with a background thread
#define LIBAVUTIL_VERSION_INT
AVIOInterruptCB interrupt_callback
const char * av_default_item_name(void *ptr)
Return the context name.
static const AVClass cache_context_class
int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx)
Wrapper to work around the lack of mkstemp() on mingw.
void * av_tree_find(const AVTreeNode *t, void *key, int(*cmp)(const void *key, const void *b), void *next[2])
static const AVOption options[]
struct AVTreeNode * av_tree_node_alloc(void)
Allocate an AVTreeNode.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const URLProtocol ff_cache_protocol
static int enu_free(void *opaque, void *elem)
miscellaneous OS support macros and functions.
static av_cold int end(AVCodecContext *avctx)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define AVERROR_EOF
End of file.
void av_tree_destroy(AVTreeNode *t)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * protocol_whitelist
simple assert() macros that are a bit more flexible than ISO C assert().
static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **options)
#define FFDIFFSIGN(x, y)
Comparator.
common internal API header
static int cache_close(URLContext *h)
static int cmp(const void *key, const void *node)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
#define AV_LOG_INFO
Standard information.
const char * protocol_blacklist
static int cache_read(URLContext *h, unsigned char *buf, int size)
Describe the class of an AVClass context structure.
#define flags(name, subs,...)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h...
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
static int add_entry(URLContext *h, const unsigned char *buf, int size)
void * av_tree_insert(AVTreeNode **tp, void *key, int(*cmp)(const void *key, const void *b), AVTreeNode **next)
Insert or remove an element.
unbuffered private I/O API
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
void av_tree_enumerate(AVTreeNode *t, void *opaque, int(*cmp)(void *opaque, void *elem), int(*enu)(void *opaque, void *elem))
Apply enu(opaque, &elem) to all the elements in the tree in a given range.
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...