From 5052ab755885cae985f267eb71f8d5572b3e90a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2021 17:49:14 +1000 Subject: Cleanup: extract image loading into it's own function --- source/blender/windowmanager/intern/wm_playanim.c | 48 ++++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index a209930f978..d7fdcc7e4af 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -273,6 +273,28 @@ static struct { }; #endif /* USE_FRAME_CACHE_LIMIT */ +static ImBuf *ibuf_from_picture(PlayAnimPict *pic) +{ + ImBuf *ibuf = NULL; + + if (pic->ibuf) { + ibuf = pic->ibuf; + } + else if (pic->anim) { + ibuf = IMB_anim_absolute(pic->anim, pic->frame, IMB_TC_NONE, IMB_PROXY_NONE); + } + else if (pic->mem) { + /* use correct colorspace here */ + ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->name); + } + else { + /* use correct colorspace here */ + ibuf = IMB_loadiffname(pic->name, pic->IB_flags, NULL); + } + + return ibuf; +} + static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step) { if (step > 0) { @@ -641,14 +663,7 @@ static void build_pict_list_ex( if (ptottime > 1.0) { /* OCIO_TODO: support different input color space */ - struct ImBuf *ibuf; - if (picture->mem) { - ibuf = IMB_ibImageFromMemory( - picture->mem, picture->size, picture->IB_flags, NULL, picture->name); - } - else { - ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL); - } + ImBuf *ibuf = ibuf_from_picture(picture); if (ibuf) { playanim_toscreen(ps, picture, ibuf, fontid, fstep); IMB_freeImBuf(ibuf); @@ -1549,21 +1564,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv) IMB_freeImBuf(ibuf); } #endif - if (ps.picture->ibuf) { - ibuf = ps.picture->ibuf; - } - else if (ps.picture->anim) { - ibuf = IMB_anim_absolute(ps.picture->anim, ps.picture->frame, IMB_TC_NONE, IMB_PROXY_NONE); - } - else if (ps.picture->mem) { - /* use correct colorspace here */ - ibuf = IMB_ibImageFromMemory( - ps.picture->mem, ps.picture->size, ps.picture->IB_flags, NULL, ps.picture->name); - } - else { - /* use correct colorspace here */ - ibuf = IMB_loadiffname(ps.picture->name, ps.picture->IB_flags, NULL); - } + + ibuf = ibuf_from_picture(ps.picture); if (ibuf) { #ifdef USE_IMB_CACHE -- cgit v1.2.3