View Full Version : Cache Hints
mg262
15th November 2005, 01:27
I'm having a bit of trouble finding a reference on how these work, either here or on the AVISynth site. Closest I can find is this, but it discusses the ambiguity more than the correct usage.
http://forum.doom9.org/showthread.php?p=696737#post696737
Does it work like this: a filter can call the SetCacheHints method of child and any other PClips which it has been passed as arguments, specifying for each one which frames are needed? Is it possible for a filter to specify that its own output should not be cached -- perhaps by calling its own SetCacheHints with CACHE_NOTHING?
:confused: I would be grateful for any clarification!
IanB
15th November 2005, 13:40
Does it work like this: a filter can call the SetCacheHints method of child and any other PClips which it has been passed as arguments, specifying for each one which frames are needed?Yes, for each PClip that you request multiple frames per input request.
SetCacheHints(CACHE_RANGE, K) should be used in filters that request multiple frames numbers from any single PClip source per input GetFrame call.
E.g. If you have a single PClip source, i.e. child and you get asked for frame 100 and you in turn then ask for frames 98, 99, 100, 101 and 102 then CACHE_RANGE IS for you. K in this case should be set to 3.
E.g. If you have 2 PClip sources and you get asked for frame 100 and you only ask each source for frame 100, the CACHE_RANGE is NOT for you.
In version 2.5.6 there is some legacy protection for unreasonable values of K.
1. K<=1 is ignored, normal cacheing used.
2. K==2, then K=3
3. K>21, then K=21 (Which I thought I had set to 11, but 21 it is)
Frames outside the specified radius are candidate for normal LRU cacheing. The 2.5.6 heuristic cache is very forgiving of bad hints.
Versions prior to version 2.5.6, K was sometimes treated as a diameter and frames outside this limit were not cached. Catastrophic cache failure was the result of bad values.
Is it possible for a filter to specify that its own output should not be cached -- perhaps by calling its own SetCacheHints with CACHE_NOTHING?No, at the time your filters constructor is being executed, it is at the top of the chain. i.e. Your parent cache does not exist yet. Even if it did exist there is no non-trickey way (digging return addresses out of the stack is very poor form) to find your parent cache instance.
Apart from that it is not appropriate to second guess the access requirements of the parent filter chain. Well maybe AVSTimer like filters might have a case.
mg262
15th November 2005, 13:50
Ian,
:thanks: very much -- that was very clear.
Apart from that it is not appropriate to second guess the access requirements of the parent filter chain. Well maybe AVSTimer like filters might have a case.+ filters that cache their own output. I don't like second-guessing/displacing the AVISynth cache, but sometimes it is hard to avoid. For example, recursive filters, i.e. where Filter->GetFrame(20,...) needs the output of Filter->GetFrame(19,...), which in turn needs... . AFAICS such a filter has to keep its own cache? Another example is for pseudo-filters that return a very small amount of data [e.g. global motion per frame].
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.