00001 #ifndef FRAMECACHE_H
00002 #define FRAMECACHE_H
00003
00004
00005 #include "arraylist.h"
00006 #include "mutex.inc"
00007 #include "vframe.inc"
00008
00009
00010 #include <stdint.h>
00011
00012
00013
00014
00015
00016
00017 class FrameCacheItem
00018 {
00019 public:
00020 FrameCacheItem();
00021 ~FrameCacheItem();
00022
00023 VFrame *data;
00024 int64_t position;
00025 double frame_rate;
00026
00027 int age;
00028 };
00029
00030 class FrameCache
00031 {
00032 public:
00033 FrameCache();
00034 ~FrameCache();
00035
00036
00037 int get_frame(VFrame *frame,
00038 int64_t position,
00039 double frame_rate);
00040
00041
00042
00043
00044 VFrame* get_frame_ptr(int64_t position,
00045 double frame_rate,
00046 int color_model,
00047 int w,
00048 int h);
00049 void unlock();
00050
00051
00052
00053 void put_frame(VFrame *frame,
00054 int64_t position,
00055 double frame_rate,
00056 int use_copy);
00057
00058
00059 int delete_oldest();
00060
00061
00062 int64_t get_memory_usage();
00063 void dump();
00064
00065
00066
00067
00068 private:
00069
00070
00071 int frame_exists(VFrame *format,
00072 int64_t position,
00073 double frame_rate,
00074 int *item_return);
00075 int FrameCache::frame_exists(int64_t position,
00076 double frame_rate,
00077 int color_model,
00078 int w,
00079 int h,
00080 int *item_return);
00081
00082 Mutex *lock;
00083
00084 int current_age;
00085 ArrayList<FrameCacheItem*> items;
00086
00087 int64_t max_bytes;
00088 };
00089
00090
00091
00092 #endif