[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38989] branches/soc-2011-tomato/source/ blender/blenkernel: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Wed Aug 3 16:04:33 CEST 2011
Revision: 38989
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38989
Author: nazgul
Date: 2011-08-03 14:04:33 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================
Get rid of cachin logic in seqcache, switch it to use logic
from movie clip. Now only hash calculation and comparator
functions are declared in seqcache.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
branches/soc-2011-tomato/source/blender/blenkernel/BKE_sequencer.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-08-03 14:02:08 UTC (rev 38988)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-08-03 14:04:33 UTC (rev 38989)
@@ -34,6 +34,7 @@
* \author Sergey Sharybin
*/
+#include "BLI_utildefines.h"
#include "BLI_ghash.h"
/* Cache system for movie data - now supports stroting ImBufs only
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_sequencer.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_sequencer.h 2011-08-03 14:02:08 UTC (rev 38988)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_sequencer.h 2011-08-03 14:04:33 UTC (rev 38989)
@@ -212,9 +212,7 @@
SEQ_STRIPELEM_IBUF_ENDSTILL
} seq_stripelem_ibuf_t;
-void seq_stripelem_cache_init(void);
void seq_stripelem_cache_destruct(void);
-
void seq_stripelem_cache_cleanup(void);
/* returned ImBuf is properly refed and has to be freed */
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c 2011-08-03 14:02:08 UTC (rev 38988)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c 2011-08-03 14:04:33 UTC (rev 38989)
@@ -19,6 +19,8 @@
*
* Peter Schlaile <peter [at] schlaile [dot] de> 2010
*
+ * Contributor(s): Sergey Sharybin
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -28,22 +30,15 @@
#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
+#include "BLO_sys_types.h" /* for intptr_t */
+
#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
#include "DNA_sequence_types.h"
#include "BKE_sequencer.h"
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_mempool.h"
-#include <pthread.h>
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
+#include "BKE_moviecache.h"
typedef struct seqCacheKey
{
@@ -53,20 +48,9 @@
seq_stripelem_ibuf_t type;
} seqCacheKey;
-typedef struct seqCacheEntry
-{
- ImBuf * ibuf;
- MEM_CacheLimiterHandleC * c_handle;
-} seqCacheEntry;
+struct MovieCache *moviecache = NULL;
-static GHash * hash = NULL;
-static MEM_CacheLimiterC * limitor = NULL;
-static struct BLI_mempool * entrypool = NULL;
-static struct BLI_mempool * keypool = NULL;
-static int ibufs_in = 0;
-static int ibufs_rem = 0;
-
-static unsigned int HashHash(const void *key_)
+static unsigned int seqcache_hashhash(const void *key_)
{
const seqCacheKey *key = (seqCacheKey*) key_;
unsigned int rval = seq_hash_render_data(&key->context);
@@ -78,7 +62,7 @@
return rval;
}
-static int HashCmp(const void *a_, const void *b_)
+static int seqcache_hashcmp(const void *a_, const void *b_)
{
const seqCacheKey * a = (seqCacheKey*) a_;
const seqCacheKey * b = (seqCacheKey*) b_;
@@ -107,109 +91,37 @@
return seq_cmp_render_data(&a->context, &b->context);
}
-static void HashKeyFree(void *key)
-{
- BLI_mempool_free(keypool, key);
-}
-
-static void HashValFree(void *val)
-{
- seqCacheEntry* e = (seqCacheEntry*) val;
-
- if (e->ibuf) {
- /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf,
- e->ibuf->refcounter); */
- IMB_freeImBuf(e->ibuf);
- MEM_CacheLimiter_unmanage(e->c_handle);
- ibufs_rem++;
- }
-
- e->ibuf = NULL;
- e->c_handle = NULL;
-
- BLI_mempool_free(entrypool, e);
-}
-
-static void IMB_seq_cache_destructor(void * p)
-{
- seqCacheEntry* e = (seqCacheEntry*) p;
-
- if (e && e->ibuf) {
- /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf,
- e->ibuf->refcounter); */
- IMB_freeImBuf(e->ibuf);
- ibufs_rem++;
-
- e->ibuf = NULL;
- e->c_handle = NULL;
- }
-}
-
-void seq_stripelem_cache_init(void)
-{
- hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");
- limitor = new_MEM_CacheLimiter( IMB_seq_cache_destructor, NULL );
-
- entrypool = BLI_mempool_create(sizeof(seqCacheEntry), 64, 64, 0);
- keypool = BLI_mempool_create(sizeof(seqCacheKey), 64, 64, 0);
-}
-
void seq_stripelem_cache_destruct(void)
{
- if (!entrypool) {
- return;
- }
- BLI_ghash_free(hash, HashKeyFree, HashValFree);
- delete_MEM_CacheLimiter(limitor);
- BLI_mempool_destroy(entrypool);
- BLI_mempool_destroy(keypool);
+ if(moviecache)
+ BKE_moviecache_free(moviecache);
}
void seq_stripelem_cache_cleanup(void)
{
- if (!entrypool) {
- seq_stripelem_cache_init();
+ if(moviecache) {
+ BKE_moviecache_free(moviecache);
+ moviecache = BKE_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
+ seqcache_hashcmp, NULL);
}
-
- /* fprintf(stderr, "Stats before cleanup: in: %d rem: %d\n",
- ibufs_in, ibufs_rem); */
-
- BLI_ghash_free(hash, HashKeyFree, HashValFree);
- hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");
-
- /* fprintf(stderr, "Stats after cleanup: in: %d rem: %d\n",
- ibufs_in, ibufs_rem); */
-
}
struct ImBuf * seq_stripelem_cache_get(
SeqRenderData context, struct Sequence * seq,
float cfra, seq_stripelem_ibuf_t type)
{
- seqCacheKey key;
- seqCacheEntry * e;
- if (!seq) {
- return NULL;
- }
+ if(moviecache && seq) {
+ seqCacheKey key;
- if (!entrypool) {
- seq_stripelem_cache_init();
- }
+ key.seq = seq;
+ key.context = context;
+ key.cfra = cfra - seq->start;
+ key.type = type;
- key.seq = seq;
- key.context = context;
- key.cfra = cfra - seq->start;
- key.type = type;
-
- e = (seqCacheEntry*) BLI_ghash_lookup(hash, &key);
-
- if (e && e->ibuf) {
- IMB_refImBuf(e->ibuf);
-
- MEM_CacheLimiter_touch(e->c_handle);
- return e->ibuf;
+ return BKE_moviecache_get(moviecache, &key);
}
+
return NULL;
}
@@ -217,39 +129,21 @@
SeqRenderData context, struct Sequence * seq,
float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i)
{
- seqCacheKey * key;
- seqCacheEntry * e;
+ seqCacheKey key;
if (!i) {
return;
}
- ibufs_in++;
-
- if (!entrypool) {
- seq_stripelem_cache_init();
+ if(!moviecache) {
+ moviecache = BKE_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
+ seqcache_hashcmp, NULL);
}
- key = (seqCacheKey*) BLI_mempool_alloc(keypool);
+ key.seq = seq;
+ key.context = context;
+ key.cfra = cfra - seq->start;
+ key.type = type;
- key->seq = seq;
- key->context = context;
- key->cfra = cfra - seq->start;
- key->type = type;
-
- IMB_refImBuf(i);
-
- e = (seqCacheEntry*) BLI_mempool_alloc(entrypool);
-
- e->ibuf = i;
- e->c_handle = NULL;
-
- BLI_ghash_remove(hash, key, HashKeyFree, HashValFree);
- BLI_ghash_insert(hash, key, e);
-
- e->c_handle = MEM_CacheLimiter_insert(limitor, e);
-
- MEM_CacheLimiter_ref(e->c_handle);
- MEM_CacheLimiter_enforce_limits(limitor);
- MEM_CacheLimiter_unref(e->c_handle);
+ BKE_moviecache_put(moviecache, &key, i);
}
More information about the Bf-blender-cvs
mailing list