Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Babahin <tamerlan311@gmail.com>2014-02-04 13:16:21 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-02-04 13:26:57 +0400
commit5589016e2446ee80028628cdde034eaeafcd7add (patch)
tree5ba88541ffbe3c2590a721ad27b48bec41c8a761
parentb29bfd5daa6b6663f6cfad3bb8ac6e61a02861db (diff)
Fix T38440: Segmentation fault in Movie Clip Editor
Issue was caused by NULL-pointer de-reference when post-processing the frame without putting the frame to movie cache. Differential Revision: https://developer.blender.org/D276
-rw-r--r--source/blender/blenkernel/intern/movieclip.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 4ea98650551..39c3b96f66e 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -780,12 +780,35 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use
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)
+{
+ 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,
+ 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;
+}
+
+static void put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf,
int flag, int postprocess_flag)
{
MovieClipCache *cache = clip->cache;
MovieTrackingCamera *camera = &clip->tracking.camera;
- ImBuf *postproc_ibuf = NULL;
cache->postprocessed.framenr = user->framenr;
cache->postprocessed.flag = postprocess_flag;
@@ -803,31 +826,17 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
copy_v2_v2(cache->postprocessed.principal, camera->principal);
copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
cache->postprocessed.undistortion_used = TRUE;
- postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
}
else {
cache->postprocessed.undistortion_used = FALSE;
- postproc_ibuf = IMB_dupImBuf(ibuf);
}
- if (postprocess_flag) {
- 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);
+ IMB_refImBuf(ibuf);
if (cache->postprocessed.ibuf)
IMB_freeImBuf(cache->postprocessed.ibuf);
- cache->postprocessed.ibuf = postproc_ibuf;
-
- return postproc_ibuf;
+ cache->postprocessed.ibuf = ibuf;
}
static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag,
@@ -873,11 +882,14 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u
clip->lastframe = framenr;
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) {
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);
+ if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) {
+ put_postprocessed_frame_to_cache(clip, user, ibuf, flag, postprocess_flag);
+ }
}
}