r858: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / framecache.h
blobe42ce71cf046f979f016a49b4e77f65a782ac051
1 #ifndef FRAMECACHE_H
2 #define FRAMECACHE_H
5 #include "cachebase.h"
6 #include "mutex.inc"
7 #include "vframe.inc"
10 #include <stdint.h>
12 // Simply a table of images described by frame position and dimensions.
13 // The frame position is relative to the frame rate of the source file.
14 // This object is used by File for playback.
15 // and MWindow for timeline drawing.
16 // CICache scans all the files for
17 // frame caches and deletes what's needed to maintain the cache size.
19 class FrameCacheItem : public CacheItemBase
21 public:
22 FrameCacheItem();
23 ~FrameCacheItem();
25 int get_size();
27 VFrame *data;
28 double frame_rate;
31 class FrameCache : public CacheBase
33 public:
34 FrameCache();
35 ~FrameCache();
37 // Returns 1 if frame exists in cache and copies it to the frame argument.
38 int get_frame(VFrame *frame,
39 int64_t position,
40 double frame_rate);
41 // Returns pointer to cache entry if frame exists or 0.
42 // If a frame is found, the frame cache is left in the locked state until
43 // unlock is called. If nothing is found, the frame cache is unlocked before
44 // returning. This keeps the item from being deleted.
45 VFrame* get_frame_ptr(int64_t position,
46 double frame_rate,
47 int color_model,
48 int w,
49 int h);
50 // Puts the frame in cache.
51 // use_copy - if 1 a copy of the frame is made. if 0 the argument is stored.
52 // The copy of the frame is deleted by FrameCache in a future delete_oldest.
53 void put_frame(VFrame *frame,
54 int64_t position,
55 double frame_rate,
56 int use_copy);
58 void dump();
63 private:
64 // Return 1 if matching frame exists.
65 // Return 0 if not.
66 int frame_exists(VFrame *format,
67 int64_t position,
68 double frame_rate,
69 FrameCacheItem **item_return);
70 int frame_exists(int64_t position,
71 double frame_rate,
72 int color_model,
73 int w,
74 int h,
75 FrameCacheItem **item_return);
80 #endif