[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41038] branches/soc-2011-tomato/source/ blender: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Sat Oct 15 21:20:34 CEST 2011
Revision: 41038
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41038
Author: nazgul
Date: 2011-10-15 19:20:34 +0000 (Sat, 15 Oct 2011)
Log Message:
-----------
Camera tracking integration
===========================
Changes to moviecache pointed and discussed in codereview page:
http://codereview.appspot.com/5283049/
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/CMakeLists.txt
branches/soc-2011-tomato/source/blender/blenkernel/intern/blender.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/seqcache.c
branches/soc-2011-tomato/source/blender/imbuf/CMakeLists.txt
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/imbuf/IMB_moviecache.h
branches/soc-2011-tomato/source/blender/imbuf/intern/moviecache.c
Removed Paths:
-------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
Deleted: branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-10-15 19:19:24 UTC (rev 41037)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h 2011-10-15 19:20:34 UTC (rev 41038)
@@ -1,58 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation,
- * Sergey Sharybin
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef BKE_MOVIECACHE_H
-#define BKE_MOVIECACHE_H
-
-/** \file BKE_moviecache.h
- * \ingroup bke
- * \author Sergey Sharybin
- */
-
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-
-/* Cache system for movie data - now supports stroting ImBufs only
- Supposed to provide unified cache system for movie clips, sequencer and
- other movie-related areas */
-
-struct ImBuf;
-struct MovieCache;
-
-typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr, int *proxy, int *render_flags);
-
-void BKE_moviecache_init(void);
-void BKE_moviecache_destruct(void);
-
-struct MovieCache *BKE_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp, MovieCacheGetKeyDataFP getdatafp);
-void BKE_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
-struct ImBuf* BKE_moviecache_get(struct MovieCache *cache, void *userkey);
-void BKE_moviecache_free(struct MovieCache *cache);
-void BKE_moviecache_get_cache_segments(struct MovieCache *cache, int proxy, int render_flags, int *totseg_r, int **points_r);
-
-#endif
Modified: branches/soc-2011-tomato/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/CMakeLists.txt 2011-10-15 19:19:24 UTC (rev 41037)
+++ branches/soc-2011-tomato/source/blender/blenkernel/CMakeLists.txt 2011-10-15 19:20:34 UTC (rev 41038)
@@ -117,7 +117,6 @@
intern/mesh_validate.c
intern/modifier.c
intern/movieclip.c
- intern/moviecache.c
intern/multires.c
intern/nla.c
intern/node.c
@@ -202,7 +201,6 @@
BKE_mesh.h
BKE_modifier.h
BKE_movieclip.h
- BKE_moviecache.h
BKE_multires.h
BKE_nla.h
BKE_node.h
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/blender.c 2011-10-15 19:19:24 UTC (rev 41037)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/blender.c 2011-10-15 19:20:34 UTC (rev 41038)
@@ -64,6 +64,7 @@
#include "BLI_callbacks.h"
#include "IMB_imbuf.h"
+#include "IMB_moviecache.h"
#include "BKE_blender.h"
#include "BKE_context.h"
@@ -80,7 +81,6 @@
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_sound.h"
-#include "BKE_moviecache.h"
#include "BLO_undofile.h"
@@ -115,7 +115,7 @@
BLI_cb_finalize();
seq_stripelem_cache_destruct();
- BKE_moviecache_destruct();
+ IMB_moviecache_destruct();
free_nodesystem();
}
Deleted: branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c 2011-10-15 19:19:24 UTC (rev 41037)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c 2011-10-15 19:20:34 UTC (rev 41038)
@@ -1,381 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation,
- * Sergey Sharybin,
- * Peter Schlaile
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenkernel/intern/moviecache.c
- * \ingroup bke
- */
-
-#include "MEM_guardedalloc.h"
-#include "MEM_CacheLimiterC-Api.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_ghash.h"
-#include "BLI_mempool.h"
-
-#include "BKE_moviecache.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-
-static MEM_CacheLimiterC *limitor= NULL;
-
-typedef struct MovieCache {
- GHash *hash;
- GHashHashFP hashfp;
- GHashCmpFP cmpfp;
- MovieCacheGetKeyDataFP getdatafp;
-
- struct BLI_mempool *keys_pool;
- struct BLI_mempool *items_pool;
- struct BLI_mempool *userkeys_pool;
-
- int keysize;
- unsigned long curtime;
-
- int totseg, *points, proxy, render_flags; /* for visual statistics optimization */
- int pad;
-} MovieCache;
-
-typedef struct MovieCacheKey {
- MovieCache *cache_owner;
- void *userkey;
-} MovieCacheKey;
-
-typedef struct MovieCacheItem {
- MovieCache *cache_owner;
- ImBuf *ibuf;
- MEM_CacheLimiterHandleC * c_handle;
- unsigned long last_access;
-} MovieCacheItem;
-
-static unsigned int moviecache_hashhash(const void *keyv)
-{
- MovieCacheKey *key= (MovieCacheKey*)keyv;
-
- return key->cache_owner->hashfp(key->userkey);
-}
-
-static int moviecache_hashcmp(const void *av, const void *bv)
-{
- const MovieCacheKey *a= (MovieCacheKey*)av;
- const MovieCacheKey *b= (MovieCacheKey*)bv;
-
- return a->cache_owner->cmpfp(a->userkey, b->userkey);
-}
-
-static void moviecache_keyfree(void *val)
-{
- MovieCacheKey *key= (MovieCacheKey*)val;
-
- BLI_mempool_free(key->cache_owner->keys_pool, key);
-}
-
-static void moviecache_valfree(void *val)
-{
- MovieCacheItem *item= (MovieCacheItem*)val;
-
- if (item->ibuf) {
- MEM_CacheLimiter_unmanage(item->c_handle);
- IMB_freeImBuf(item->ibuf);
- }
-
- BLI_mempool_free(item->cache_owner->items_pool, item);
-}
-
-static void check_unused_keys(MovieCache *cache)
-{
- GHashIterator *iter;
-
- iter= BLI_ghashIterator_new(cache->hash);
- while(!BLI_ghashIterator_isDone(iter)) {
- MovieCacheKey *key= BLI_ghashIterator_getKey(iter);
- MovieCacheItem *item= BLI_ghashIterator_getValue(iter);
-
- BLI_ghashIterator_step(iter);
-
- if(!item->ibuf)
- BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree);
- }
-
- BLI_ghashIterator_free(iter);
-}
-
-static int compare_int(const void *av, const void *bv)
-{
- const int *a= (int *)av;
- const int *b= (int *)bv;
- return *a-*b;
-}
-
-static void IMB_moviecache_destructor(void *p)
-{
- MovieCacheItem *item= (MovieCacheItem *) p;
-
- if (item && item->ibuf) {
- IMB_freeImBuf(item->ibuf);
-
- item->ibuf= NULL;
- item->c_handle= NULL;
- }
-}
-
-/* approximate size of ImBuf in memory */
-static intptr_t IMB_get_size_in_memory(ImBuf *ibuf)
-{
- int a;
- intptr_t size= 0, channel_size= 0;
-
- size+= sizeof(ImBuf);
-
- if(ibuf->rect)
- channel_size+= sizeof(char);
-
- if(ibuf->rect_float)
- channel_size= sizeof(float);
-
- size+= channel_size*ibuf->x*ibuf->y*ibuf->channels;
-
- if(ibuf->miptot) {
- for(a= 0; a<ibuf->miptot; a++) {
- if(ibuf->mipmap[a])
- size+= IMB_get_size_in_memory(ibuf->mipmap[a]);
- }
- }
-
- if(ibuf->tiles) {
- size+= sizeof(unsigned int)*ibuf->ytiles*ibuf->xtiles;
- }
-
- return size;
-}
-
-static intptr_t get_item_size (void *p)
-{
- intptr_t size= sizeof(MovieCacheItem);
- MovieCacheItem *item= (MovieCacheItem *) p;
-
- if(item->ibuf)
- size+= IMB_get_size_in_memory(item->ibuf);
-
- return size;
-}
-
-void BKE_moviecache_init(void)
-{
- limitor= new_MEM_CacheLimiter(IMB_moviecache_destructor, get_item_size);
-}
-
-void BKE_moviecache_destruct(void)
-{
- if(limitor)
- delete_MEM_CacheLimiter(limitor);
-}
-
-struct MovieCache *BKE_moviecache_create(int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp,
- MovieCacheGetKeyDataFP getdatafp)
-{
- MovieCache *cache;
-
- cache= MEM_callocN(sizeof(MovieCache), "MovieCache");
- cache->keys_pool= BLI_mempool_create(sizeof(MovieCacheKey), 64, 64, 0);
- cache->items_pool= BLI_mempool_create(sizeof(MovieCacheItem), 64, 64, 0);
- cache->userkeys_pool= BLI_mempool_create(keysize, 64, 64, 0);
- cache->hash= BLI_ghash_new(moviecache_hashhash, moviecache_hashcmp, "MovieClip ImBuf cache hash");
-
- cache->keysize= keysize;
- cache->hashfp= hashfp;
- cache->cmpfp= cmpfp;
- cache->getdatafp= getdatafp;
- cache->proxy= -1;
-
- return cache;
-}
-
-void BKE_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf)
-{
- MovieCacheKey *key;
- MovieCacheItem *item;
-
- if(!limitor)
- BKE_moviecache_init();
-
- IMB_refImBuf(ibuf);
-
- key= BLI_mempool_alloc(cache->keys_pool);
- key->cache_owner= cache;
- key->userkey= BLI_mempool_alloc(cache->userkeys_pool);;
- memcpy(key->userkey, userkey, cache->keysize);
-
- item= BLI_mempool_alloc(cache->items_pool);
- item->ibuf= ibuf;
- item->cache_owner= cache;
- item->last_access= cache->curtime++;
- item->c_handle= NULL;
-
- BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree);
- BLI_ghash_insert(cache->hash, key, item);
-
- item->c_handle= MEM_CacheLimiter_insert(limitor, item);
-
- MEM_CacheLimiter_ref(item->c_handle);
- MEM_CacheLimiter_enforce_limits(limitor);
- MEM_CacheLimiter_unref(item->c_handle);
-
- /* cache limiter can't remove unused keys which points to destoryed values */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list