diff options
Diffstat (limited to 'source/blender/blenkernel/intern/movieclip.c')
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index e28adb7c0e0..7a8c4ad4564 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -69,7 +69,6 @@ #include "BKE_image.h" /* openanim */ #include "BKE_tracking.h" -#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_moviecache.h" @@ -78,8 +77,6 @@ # include "intern/openexr/openexr_multi.h" #endif -#include "NOD_composite.h" - /*********************** movieclip buffer loaders *************************/ static int sequence_guess_offset(const char *full_name, int head_len, unsigned short numlen) @@ -225,14 +222,14 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, colorspace = clip->colorspace_settings.name; } - loadflag = IB_rect | IB_multilayer | IB_alphamode_detect; + loadflag = IB_rect | IB_multilayer | IB_alphamode_detect | IB_metadata; /* read ibuf */ ibuf = IMB_loadiffname(name, loadflag, colorspace); #ifdef WITH_OPENEXR if (ibuf) { - if (ibuf->ftype == OPENEXR && ibuf->userdata) { + if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) { IMB_exr_close(ibuf->userdata); ibuf->userdata = NULL; } @@ -391,7 +388,7 @@ static int user_frame_to_cache_frame(MovieClip *clip, int framenr) static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; + const MovieClipImBufCacheKey *key = userkey; *framenr = key->framenr; *proxy = key->proxy; @@ -400,7 +397,7 @@ static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *ren static unsigned int moviecache_hashhash(const void *keyv) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)keyv; + const MovieClipImBufCacheKey *key = keyv; int rval = key->framenr; return rval; @@ -408,8 +405,8 @@ static unsigned int moviecache_hashhash(const void *keyv) static bool moviecache_hashcmp(const void *av, const void *bv) { - const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey *)av; - const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey *)bv; + const MovieClipImBufCacheKey *a = av; + const MovieClipImBufCacheKey *b = bv; return ((a->framenr != b->framenr) || (a->proxy != b->proxy) || @@ -528,6 +525,15 @@ static bool put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i } } +static bool moviecache_check_free_proxy(ImBuf *UNUSED(ibuf), + void *userkey, + void *UNUSED(userdata)) +{ + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; + + return !(key->proxy == IMB_PROXY_NONE && key->render_flag == 0); +} + /*********************** common functions *************************/ /* only image block itself */ @@ -615,7 +621,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) BLI_strncpy(strtest, clip->name, sizeof(clip->name)); BLI_path_abs(strtest, G.main->name); - if (strcmp(strtest, str) == 0) { + if (STREQ(strtest, str)) { BLI_strncpy(clip->name, name, sizeof(clip->name)); /* for stringcode */ clip->id.us++; /* officially should not, it doesn't link here! */ @@ -784,10 +790,10 @@ static ImBuf *postprocess_frame(MovieClip *clip, MovieClipUser *user, ImBuf *ibu } if (postprocess_flag) { - bool disable_red = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0, - disable_green = (postprocess_flag & MOVIECLIP_DISABLE_GREEN) != 0, - disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0, - grayscale = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0; + bool disable_red = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0; + bool disable_green = (postprocess_flag & MOVIECLIP_DISABLE_GREEN) != 0; + bool disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0; + bool grayscale = (postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE) != 0; if (disable_red || disable_green || disable_blue || grayscale) BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1); @@ -1123,15 +1129,15 @@ void BKE_movieclip_get_aspect(MovieClip *clip, float *aspx, float *aspy) } /* get segments of cached frames. useful for debugging cache policies */ -void BKE_movieclip_get_cache_segments(MovieClip *clip, MovieClipUser *user, int *totseg_r, int **points_r) +void BKE_movieclip_get_cache_segments(MovieClip *clip, MovieClipUser *user, int *r_totseg, int **r_points) { - *totseg_r = 0; - *points_r = NULL; + *r_totseg = 0; + *r_points = NULL; if (clip->cache) { int proxy = rendersize_to_proxy(user, clip->flag); - IMB_moviecache_get_cache_segments(clip->cache->moviecache, proxy, user->render_flag, totseg_r, points_r); + IMB_moviecache_get_cache_segments(clip->cache->moviecache, proxy, user->render_flag, r_totseg, r_points); } } @@ -1162,7 +1168,7 @@ static void free_buffers(MovieClip *clip) clip->anim = NULL; } - BKE_free_animdata((ID *) clip); + BKE_animdata_free((ID *) clip); } void BKE_movieclip_clear_cache(MovieClip *clip) @@ -1170,6 +1176,15 @@ void BKE_movieclip_clear_cache(MovieClip *clip) free_buffers(clip); } +void BKE_movieclip_clear_proxy_cache(MovieClip *clip) +{ + if (clip->cache && clip->cache->moviecache) { + IMB_moviecache_cleanup(clip->cache->moviecache, + moviecache_check_free_proxy, + NULL); + } +} + void BKE_movieclip_reload(MovieClip *clip) { /* clear cache */ @@ -1261,7 +1276,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip scopes->frame_width = ibuf->x; scopes->frame_height = ibuf->y; - scopes->use_track_mask = track->flag & TRACK_PREVIEW_ALPHA; + scopes->use_track_mask = (track->flag & TRACK_PREVIEW_ALPHA) != 0; } IMB_freeImBuf(ibuf); @@ -1307,8 +1322,8 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty); quality = clip->proxy.quality; - scaleibuf->ftype = JPG | quality; - + scaleibuf->ftype = IMB_FTYPE_JPG; + scaleibuf->foptions.quality = quality; /* unsupported feature only confuses other s/w */ if (scaleibuf->planes == 32) scaleibuf->planes = 24; |