r863: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / framecache.h
blob272e413f4aa0bbe5cc8614740e265611a223cda5
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 *asset = 0);
67 void dump();
72 private:
73 // Return 1 if matching frame exists.
74 // Return 0 if not.
75 int frame_exists(VFrame *format,
76 int64_t position,
77 int layer,
78 double frame_rate,
79 FrameCacheItem **item_return,
80 int asset_id);
81 int frame_exists(int64_t position,
82 int layer,
83 double frame_rate,
84 int color_model,
85 int w,
86 int h,
87 FrameCacheItem **item_return,
88 int asset_id);
93 #endif