Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / framecache.h
blobfe18f3e69d7d0c2e002b9ddf2b996bfeb8b81317
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;
29 int layer;
32 class FrameCache : public CacheBase
34 public:
35 FrameCache();
36 ~FrameCache();
38 // Returns 1 if frame exists in cache and copies it to the frame argument.
39 int get_frame(VFrame *frame,
40 int64_t position,
41 int layer,
42 double frame_rate,
43 int asset_id = -1);
44 // Returns pointer to cache entry if frame exists or 0.
45 // If a frame is found, the frame cache is left in the locked state until
46 // unlock is called. If nothing is found, the frame cache is unlocked before
47 // returning. This keeps the item from being deleted.
48 // asset - supplied by user if the cache is not part of a file.
49 VFrame* get_frame_ptr(int64_t position,
50 int layer,
51 double frame_rate,
52 int color_model,
53 int w,
54 int h,
55 int asset_id = -1);
56 // Puts the frame in cache.
57 // use_copy - if 1 a copy of the frame is made. if 0 the argument is stored.
58 // The copy of the frame is deleted by FrameCache in a future delete_oldest.
59 // asset - supplied by user if the cache is not part of a file.
60 void put_frame(VFrame *frame,
61 int64_t position,
62 int layer,
63 double frame_rate,
64 int use_copy,
65 Asset_GC asset = Asset_GC());
67 void dump();
74 private:
75 // Return 1 if matching frame exists.
76 // Return 0 if not.
77 int frame_exists(VFrame *format,
78 int64_t position,
79 int layer,
80 double frame_rate,
81 FrameCacheItem **item_return,
82 int asset_id);
83 int frame_exists(int64_t position,
84 int layer,
85 double frame_rate,
86 int color_model,
87 int w,
88 int h,
89 FrameCacheItem **item_return,
90 int asset_id);
95 #endif
97 // Local Variables:
98 // mode: C++
99 // c-file-style: "linux"
100 // End: