From 08ab09cf04d93520118460b3d1f243313b7892b8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 5 Feb 2019 16:50:57 +0100 Subject: Clip editor: Fixes for prefetch Seems metadata was never read while prefetching, at least was never requested to be read. Also fixed prefetch for multilayer EXR. --- source/blender/blenkernel/BKE_movieclip.h | 2 ++ source/blender/blenkernel/intern/movieclip.c | 23 ++++++++++++++--------- source/blender/editors/space_clip/clip_editor.c | 6 +++++- 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index cc41e6ba084..4c3b8d05ca5 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -45,6 +45,8 @@ void BKE_movieclip_reload(struct Main *bmain, struct MovieClip *clip); void BKE_movieclip_clear_cache(struct MovieClip *clip); void BKE_movieclip_clear_proxy_cache(struct MovieClip *clip); +void BKE_movieclip_convert_multilayer_ibuf(struct ImBuf *ibuf); + struct ImBuf *BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user); struct ImBuf *BKE_movieclip_get_postprocessed_ibuf(struct MovieClip *clip, struct MovieClipUser *user, int postprocess_flag); struct ImBuf *BKE_movieclip_get_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 5d2616b7720..b67a39494c3 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -197,6 +197,8 @@ static void get_proxy_fname(const MovieClip *clip, strcat(name, ".jpg"); } +#ifdef WITH_OPENEXR + typedef struct MultilayerConvertContext { float *combined_pass; int num_combined_channels; @@ -247,12 +249,21 @@ static void movieclip_convert_multilayer_add_pass( } } +#endif /* WITH_OPENEXR */ + /* Will try to make image buffer usable when originating from the multi-layer * source. * Internally finds a first combined pass and uses that as a buffer. Not ideal, * but is better than a complete empty buffer. */ -static void movieclip_convert_multilayer(ImBuf *ibuf) +void BKE_movieclip_convert_multilayer_ibuf(struct ImBuf *ibuf) { + if (ibuf == NULL) { + return; + } +#ifdef WITH_OPENEXR + if (ibuf->ftype != IMB_FTYPE_OPENEXR || ibuf->userdata == NULL) { + return; + } MultilayerConvertContext ctx; ctx.combined_pass = NULL; ctx.num_combined_channels = 0; @@ -271,6 +282,7 @@ static void movieclip_convert_multilayer(ImBuf *ibuf) } IMB_exr_close(ibuf->userdata); ibuf->userdata = NULL; +#endif } static ImBuf *movieclip_load_sequence_file(MovieClip *clip, @@ -310,14 +322,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, /* read ibuf */ ibuf = IMB_loadiffname(name, loadflag, colorspace); - -#ifdef WITH_OPENEXR - if (ibuf) { - if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) { - movieclip_convert_multilayer(ibuf); - } - } -#endif + BKE_movieclip_convert_multilayer_ibuf(ibuf); return ibuf; } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 24103ed9054..c8694647d9d 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -773,7 +773,7 @@ static void prefetch_task_func(TaskPool * __restrict pool, void *task_data, int while ((mem = prefetch_thread_next_frame(queue, clip, &size, ¤t_frame))) { ImBuf *ibuf; MovieClipUser user = {0}; - int flag = IB_rect | IB_alphamode_detect; + int flag = IB_rect | IB_multilayer | IB_alphamode_detect | IB_metadata; int result; char *colorspace_name = NULL; const bool use_proxy = (clip->flag & MCLIP_USE_PROXY) && @@ -789,6 +789,10 @@ static void prefetch_task_func(TaskPool * __restrict pool, void *task_data, int } ibuf = IMB_ibImageFromMemory(mem, size, flag, colorspace_name, "prefetch frame"); + if (ibuf == NULL) { + continue; + } + BKE_movieclip_convert_multilayer_ibuf(ibuf); result = BKE_movieclip_put_frame_if_possible(clip, &user, ibuf); -- cgit v1.2.3