diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-24 16:13:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-24 16:13:13 +0400 |
commit | 385c72f5f26ae9c86bf40c127c44216ceea0e6c1 (patch) | |
tree | 6c0432578abee5437adc94e96b5a91c593b866b4 /source/blender/blenkernel/intern/movieclip.c | |
parent | 5841d1c8145ba50addeb17fa0231705d949d8b3d (diff) | |
parent | b5ce1b1a23a3befbcc4cd3c67a5ec6a76d77aa5a (diff) |
Merged changes in the trunk up to revision 55546.
Conflicts resolved:
source/blenderplayer/bad_level_call_stubs/SConscript
Partly reverted changes to intern/cycles/blender/addon/ui.py in revision 52899
to make it easier to merge trunk changes.
Diffstat (limited to 'source/blender/blenkernel/intern/movieclip.c')
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 86 |
1 files changed, 80 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 821c8fe3bda..49a64d8e478 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -457,7 +457,29 @@ static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) return NULL; } -static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag) +static int has_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) +{ + if (clip->cache) { + MovieClipImBufCacheKey key; + + key.framenr = user->framenr; + + if (flag & MCLIP_USE_PROXY) { + key.proxy = rendersize_to_proxy(user, flag); + key.render_flag = user->render_flag; + } + else { + key.proxy = IMB_PROXY_NONE; + key.render_flag = 0; + } + + return IMB_moviecache_has_frame(clip->cache->moviecache, &key); + } + + return FALSE; +} + +static bool put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, bool destructive) { MovieClipImBufCacheKey key; @@ -489,7 +511,13 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i key.render_flag = 0; } - IMB_moviecache_put(clip->cache->moviecache, &key, ibuf); + if (destructive) { + IMB_moviecache_put(clip->cache->moviecache, &key, ibuf); + return true; + } + else { + return IMB_moviecache_put_if_possible(clip->cache->moviecache, &key, ibuf); + } } /*********************** common functions *************************/ @@ -814,7 +842,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u } if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) - put_imbuf_cache(clip, user, ibuf, flag); + put_imbuf_cache(clip, user, ibuf, flag, true); } if (ibuf) { @@ -1111,6 +1139,7 @@ void BKE_movieclip_reload(MovieClip *clip) free_buffers(clip); clip->tracking.stabilization.ok = FALSE; + clip->prefetch_ok = FALSE; /* update clip source */ detect_clip_source(clip); @@ -1420,13 +1449,58 @@ float BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, float framenr) return framenr + (float) clip->start_frame - 1.0f; } -void BKE_movieclip_filename_for_frame(MovieClip *clip, int framenr, char *name) +void BKE_movieclip_filename_for_frame(MovieClip *clip, MovieClipUser *user, char *name) { - if (clip->source != MCLIP_SRC_MOVIE) { - get_sequence_fname(clip, framenr, name); + if (clip->source == MCLIP_SRC_SEQUENCE) { + int use_proxy; + + use_proxy = (clip->flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; + + if (use_proxy) { + int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT; + get_proxy_fname(clip, user->render_size, undistort, user->framenr, name); + } + else { + get_sequence_fname(clip, user->framenr, name); + } } else { BLI_strncpy(name, clip->name, FILE_MAX); BLI_path_abs(name, ID_BLEND_PATH(G.main, &clip->id)); } } + +ImBuf *BKE_movieclip_anim_ibuf_for_frame(MovieClip *clip, MovieClipUser *user) +{ + ImBuf *ibuf = NULL; + + if (clip->source == MCLIP_SRC_MOVIE) { + BLI_lock_thread(LOCK_MOVIECLIP); + ibuf = movieclip_load_movie_file(clip, user, user->framenr, clip->flag); + BLI_unlock_thread(LOCK_MOVIECLIP); + } + + return ibuf; +} + +int BKE_movieclip_has_cached_frame(MovieClip *clip, MovieClipUser *user) +{ + int has_frame = FALSE; + + BLI_lock_thread(LOCK_MOVIECLIP); + has_frame = has_imbuf_cache(clip, user, clip->flag); + BLI_unlock_thread(LOCK_MOVIECLIP); + + return has_frame; +} + +int BKE_movieclip_put_frame_if_possible(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf) +{ + bool result; + + BLI_lock_thread(LOCK_MOVIECLIP); + result = put_imbuf_cache(clip, user, ibuf, clip->flag, false); + BLI_unlock_thread(LOCK_MOVIECLIP); + + return result; +} |