4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
26 #include "cachebase.h"
27 #include "indexable.inc"
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.
41 class FrameCacheItem : public CacheItemBase
54 class FrameCache : public CacheBase
60 // Returns pointer to cache entry if frame exists or 0.
61 // If a frame is found, the frame cache is left in the locked state until
62 // unlock is called. If nothing is found, the frame cache is unlocked before
63 // returning. This keeps the item from being deleted.
64 // asset - supplied by user if the cache is not part of a file.
65 VFrame* get_frame_ptr(int64_t position, int layer, double frame_rate,
66 int color_model, int w, int h, int source_id);
67 // lock and call get_vframe
68 VFrame *get_vframe(int64_t position, int w, int h,
69 int color_model, int layer, double frame_rate,
72 VFrame *get_frame(int64_t position, int w, int h,
73 int color_model, int layer, double frame_rate,
75 // Returns 1 if frame exists in cache and copies it to the frame argument.
76 int get_frame(VFrame *frame, int64_t position,
77 int layer, double frame_rate, int source_id);
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.
83 void put_vframe(VFrame *frame, int64_t position,
84 int layer, double frame_rate, int source_id);
85 // lock, call get_vframe, if exists: ret = 0; else add frame, ret = 1; unlock
86 void put_frame(VFrame *frame, int64_t position,
87 int layer, double frame_rate, int use_copy, Indexable *idxbl);
88 int get_cache_frame(VFrame *frame, int64_t position,
89 int layer, double frame_rate);
90 void put_cache_frame(VFrame *frame, int64_t position,
91 int layer, double frame_rate, int use_copy);
95 // Return 1 if matching frame exists.
97 int frame_exists(VFrame *format,
98 int64_t position, int layer, double frame_rate,
99 FrameCacheItem **item_return, int source_id);
100 int frame_exists(int64_t position, int layer, double frame_rate,
101 int w, int h, int color_model,
102 FrameCacheItem **item_return, int source_id);