fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / framecache.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef FRAMECACHE_H
23 #define FRAMECACHE_H
24
25
26 #include "cachebase.h"
27 #include "indexable.inc"
28 #include "mutex.inc"
29 #include "vframe.inc"
30
31
32 #include <stdint.h>
33
34 // Simply a table of images described by frame position and dimensions.
35 // The frame position is relative to the frame rate of the source file.
36 // This object is used by File for playback.
37 // and MWindow for timeline drawing.
38 // CICache scans all the files for
39 // frame caches and deletes what's needed to maintain the cache size.
40
41 class FrameCacheItem : public CacheItemBase
42 {
43 public:
44         FrameCacheItem();
45         ~FrameCacheItem();
46
47         int get_size();
48
49         VFrame *data;
50         double frame_rate;
51         int layer;
52 };
53
54 class FrameCache : public CacheBase
55 {
56 public:
57         FrameCache();
58         ~FrameCache();
59
60 // Returns 1 if frame exists in cache and copies it to the frame argument.
61         int get_frame(VFrame *frame,
62                 int64_t position,
63                 int layer,
64                 double frame_rate,
65                 int source_id = -1);
66 // Returns pointer to cache entry if frame exists or 0.
67 // If a frame is found, the frame cache is left in the locked state until
68 // unlock is called.  If nothing is found, the frame cache is unlocked before
69 // returning.  This keeps the item from being deleted.
70 // asset - supplied by user if the cache is not part of a file.
71         VFrame* get_frame_ptr(int64_t position,
72                 int layer,
73                 double frame_rate,
74                 int color_model,
75                 int w,
76                 int h,
77                 int source_id = -1);
78 // Puts the frame in cache.
79 // use_copy - if 1 a copy of the frame is made.  if 0 the argument is stored.
80 // The copy of the frame is deleted by FrameCache in a future delete_oldest.
81 // asset - supplied by user if the cache is not part of a file.
82         void put_frame(VFrame *frame,
83                 int64_t position,
84                 int layer,
85                 double frame_rate,
86                 int use_copy,
87                 Indexable *indexable);
88
89         void dump();
90
91
92
93
94
95 private:
96 // Return 1 if matching frame exists.
97 // Return 0 if not.
98         int frame_exists(VFrame *format,
99                 int64_t position,
100                 int layer,
101                 double frame_rate,
102                 FrameCacheItem **item_return,
103                 int source_id);
104         int frame_exists(int64_t position,
105                 int layer,
106                 double frame_rate,
107                 int color_model,
108                 int w,
109                 int h,
110                 FrameCacheItem **item_return,
111                 int source_id);
112 };
113
114
115
116 #endif