Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/movieclip.c
| Show First 20 Lines • Show All 774 Lines • ▼ Show 20 Lines | static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *user, int flag, int postprocess_flag) | ||||
| else if (cache->postprocessed.undistortion_used) | else if (cache->postprocessed.undistortion_used) | ||||
| return NULL; | return NULL; | ||||
| IMB_refImBuf(cache->postprocessed.ibuf); | IMB_refImBuf(cache->postprocessed.ibuf); | ||||
| return cache->postprocessed.ibuf; | return cache->postprocessed.ibuf; | ||||
| } | } | ||||
| static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, | static ImBuf *postprocess_frame(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int postprocess_flag) | ||||
sergey: I would call it `postprocess_frame()`. You're not making it, you're post-processing it. | |||||
| { | |||||
| ImBuf *postproc_ibuf = NULL; | |||||
| if (need_undistortion_postprocess(user)) { | |||||
| postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf); | |||||
| } | |||||
| else { | |||||
| postproc_ibuf = IMB_dupImBuf(ibuf); | |||||
| } | |||||
| if (postprocess_flag) { | |||||
| bool disable_red = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0, | |||||
Not Done Inline ActionsWhile you're on here, make it bool disable_red = (postprocess_flag & MOVIECLIP_DISABLE_RED) != 0 And same for all the rest of the channels. BKE_tracking_disable_channels() accepts bools, so passing ints could lead to some issues. Let's clean this up. sergey: While you're on here, make it
bool disable_red = (postprocess_flag &… | |||||
| disable_green = (postprocess_flag & MOVIECLIP_DISABLE_GREEN) != 0, | |||||
| disable_blue = (postprocess_flag & MOVIECLIP_DISABLE_BLUE) != 0, | |||||
| 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); | |||||
| } | |||||
| return postproc_ibuf; | |||||
Not Done Inline ActionsThis is rather weird, all the movie clip get_ibuf functions are to return referenced image buffer. Here you skip referencing which would lead to wrong user counter in the future? sergey: This is rather weird, all the movie clip get_ibuf functions are to return referenced image… | |||||
| } | |||||
| static void put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, | |||||
| int flag, int postprocess_flag) | int flag, int postprocess_flag) | ||||
| { | { | ||||
| MovieClipCache *cache = clip->cache; | MovieClipCache *cache = clip->cache; | ||||
| MovieTrackingCamera *camera = &clip->tracking.camera; | MovieTrackingCamera *camera = &clip->tracking.camera; | ||||
| ImBuf *postproc_ibuf = NULL; | |||||
| cache->postprocessed.framenr = user->framenr; | cache->postprocessed.framenr = user->framenr; | ||||
| cache->postprocessed.flag = postprocess_flag; | cache->postprocessed.flag = postprocess_flag; | ||||
| if (flag & MCLIP_USE_PROXY) { | if (flag & MCLIP_USE_PROXY) { | ||||
| cache->postprocessed.proxy = rendersize_to_proxy(user, flag); | cache->postprocessed.proxy = rendersize_to_proxy(user, flag); | ||||
| cache->postprocessed.render_flag = user->render_flag; | cache->postprocessed.render_flag = user->render_flag; | ||||
| } | } | ||||
| else { | else { | ||||
| cache->postprocessed.proxy = IMB_PROXY_NONE; | cache->postprocessed.proxy = IMB_PROXY_NONE; | ||||
| cache->postprocessed.render_flag = 0; | cache->postprocessed.render_flag = 0; | ||||
| } | } | ||||
| if (need_undistortion_postprocess(user)) { | if (need_undistortion_postprocess(user)) { | ||||
| copy_v2_v2(cache->postprocessed.principal, camera->principal); | copy_v2_v2(cache->postprocessed.principal, camera->principal); | ||||
| copy_v3_v3(&cache->postprocessed.k1, &camera->k1); | copy_v3_v3(&cache->postprocessed.k1, &camera->k1); | ||||
| cache->postprocessed.undistortion_used = TRUE; | cache->postprocessed.undistortion_used = TRUE; | ||||
| postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf); | |||||
| } | } | ||||
| else { | else { | ||||
| cache->postprocessed.undistortion_used = FALSE; | cache->postprocessed.undistortion_used = FALSE; | ||||
| postproc_ibuf = IMB_dupImBuf(ibuf); | |||||
| } | } | ||||
| if (postprocess_flag) { | IMB_refImBuf(ibuf); | ||||
| int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED, | |||||
| disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN, | |||||
| disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE, | |||||
| grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE; | |||||
| if (disable_red || disable_green || disable_blue || grayscale) | |||||
| BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1); | |||||
| } | |||||
| IMB_refImBuf(postproc_ibuf); | |||||
| if (cache->postprocessed.ibuf) | if (cache->postprocessed.ibuf) | ||||
| IMB_freeImBuf(cache->postprocessed.ibuf); | IMB_freeImBuf(cache->postprocessed.ibuf); | ||||
| cache->postprocessed.ibuf = postproc_ibuf; | cache->postprocessed.ibuf = ibuf; | ||||
| return postproc_ibuf; | |||||
| } | } | ||||
| static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag, | static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag, | ||||
| int postprocess_flag, int cache_flag) | int postprocess_flag, int cache_flag) | ||||
| { | { | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| int framenr = user->framenr, need_postprocess = FALSE; | int framenr = user->framenr, need_postprocess = FALSE; | ||||
| Show All 29 Lines | if (!ibuf) { | ||||
| if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) | if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) | ||||
| put_imbuf_cache(clip, user, ibuf, flag, true); | put_imbuf_cache(clip, user, ibuf, flag, true); | ||||
| } | } | ||||
| if (ibuf) { | if (ibuf) { | ||||
| clip->lastframe = framenr; | clip->lastframe = framenr; | ||||
| real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]); | real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]); | ||||
| /* postprocess frame and put to cache */ | /* postprocess frame and put to cache if needed*/ | ||||
| if (need_postprocess) { | if (need_postprocess) { | ||||
| ImBuf *tmpibuf = ibuf; | ImBuf *tmpibuf = ibuf; | ||||
| ibuf = put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag, postprocess_flag); | ibuf = postprocess_frame(clip, user, tmpibuf, postprocess_flag); | ||||
| IMB_freeImBuf(tmpibuf); | IMB_freeImBuf(tmpibuf); | ||||
| if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) { | |||||
| put_postprocessed_frame_to_cache(clip, user, ibuf, flag, postprocess_flag); | |||||
| } | |||||
| } | } | ||||
Not Done Inline ActionsThis could be simplified logic: ImBuf *tmpibuf = ibuf;
ibuf = make_postprocessed_frame(clip, user, tmpibuf, postprocess_flag);
IMB_freeImBuf(tmpibuf);
if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) {
put_frame_to_postprocessed_cache(...);
}This way you'll simplify put_frame_to_postprocessed_cache() a bit further. sergey: This could be simplified logic:
ImBuf *tmpibuf = ibuf;
ibuf = make_postprocessed_frame… | |||||
| } | } | ||||
| BLI_unlock_thread(LOCK_MOVIECLIP); | BLI_unlock_thread(LOCK_MOVIECLIP); | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| ImBuf *BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user) | ImBuf *BKE_movieclip_get_ibuf(MovieClip *clip, MovieClipUser *user) | ||||
| ▲ Show 20 Lines • Show All 642 Lines • Show Last 20 Lines | |||||
I would call it postprocess_frame(). You're not making it, you're post-processing it.