summaryrefslogtreecommitdiff
path: root/src/lut_cache.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-03-13 16:46:50 +0000
committerCarl Hetherington <cth@carlh.net>2013-03-13 16:46:50 +0000
commit45625f3116a09d3c8415a54bf8d19fdbb3a3aa9b (patch)
tree3619eb2ba2d9e754f9122b367f4eeffe56239bf9 /src/lut_cache.h
parent6e5411a943ef9b3f23cfb8dd9dcc1a756b55bfbe (diff)
Compute LUTs at run-time.dynamic-lut
Diffstat (limited to 'src/lut_cache.h')
-rw-r--r--src/lut_cache.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lut_cache.h b/src/lut_cache.h
new file mode 100644
index 00000000..b60ee109
--- /dev/null
+++ b/src/lut_cache.h
@@ -0,0 +1,28 @@
+#ifndef LIBDCP_LUT_CACHE_H
+#define LIBDCP_LUT_CACHE_H
+
+#include <list>
+#include <boost/shared_ptr.hpp>
+
+template<class T>
+class LUTCache
+{
+public:
+ boost::shared_ptr<T> get (int bit_depth, float gamma)
+ {
+ for (typename std::list<boost::shared_ptr<T> >::iterator i = _cache.begin(); i != _cache.end(); ++i) {
+ if ((*i)->bit_depth() == bit_depth && (*i)->gamma() == gamma) {
+ return *i;
+ }
+ }
+
+ boost::shared_ptr<T> lut (new T (bit_depth, gamma));
+ _cache.push_back (lut);
+ return lut;
+ }
+
+private:
+ std::list<boost::shared_ptr<T> > _cache;
+};
+
+#endif