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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-05-06 21:59:02 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-05-06 21:59:02 +0400
commit88129ac395ac6fb62acbef3dd436c7575e02aa3c (patch)
treeb6dd436b2a414d23684462d6306020ee28bd69a9 /source
parent9aed3f62d3861eec8cc37357738c8e936c5e3e08 (diff)
Fix for crash when using 2D stabilization for float movie clips
Also removed unneeded image buffer scaling, it was only needed for "early output" if there was no rotation. That is no longer supported since it used to pixelate result a lot and interpolation is always used now. Saves quite a few of memory and CPU cycles.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/tracking.c62
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h2
3 files changed, 13 insertions, 52 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index d7ac08bf2bc..c202a210de7 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -154,9 +154,6 @@ void BKE_tracking_free(MovieTracking *tracking)
tracking_reconstruction_free(&tracking->reconstruction);
tracking_objects_free(&tracking->objects);
- if (tracking->stabilization.scaleibuf)
- IMB_freeImBuf(tracking->stabilization.scaleibuf);
-
if (tracking->camera.intrinsics)
BKE_tracking_distortion_free(tracking->camera.intrinsics);
@@ -3488,34 +3485,6 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i
return stab->scale;
}
-static ImBuf *stabilization_allocate_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
-{
- int flags;
-
- if (cacheibuf && (cacheibuf->x != srcibuf->x || cacheibuf->y != srcibuf->y)) {
- IMB_freeImBuf(cacheibuf);
- cacheibuf = NULL;
- }
-
- flags = IB_rect;
-
- if (srcibuf->rect_float)
- flags |= IB_rectfloat;
-
- if (cacheibuf) {
- if (fill) {
- float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-
- IMB_rectfill(cacheibuf, col);
- }
- }
- else {
- cacheibuf = IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags);
- }
-
- return cacheibuf;
-}
-
/* NOTE: frame number should be in clip space, not scene space */
void BKE_tracking_stabilization_data_get(MovieTracking *tracking, int framenr, int width, int height,
float loc[2], float *scale, float *angle)
@@ -3568,6 +3537,7 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
float mat[4][4];
int j, filter = tracking->stabilization.filter;
void (*interpolation)(struct ImBuf *, struct ImBuf *, float, float, int, int) = NULL;
+ int ibuf_flags;
if (loc)
copy_v2_v2(tloc, loc);
@@ -3575,6 +3545,7 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
if (scale)
tscale = *scale;
+ /* Perform early output if no stabilization is used. */
if ((stab->flag & TRACKING_2D_STABILIZATION) == 0) {
if (loc)
zero_v2(loc);
@@ -3588,25 +3559,17 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
return ibuf;
}
- BKE_tracking_stabilization_data_get(tracking, framenr, width, height, tloc, &tscale, &tangle);
-
- tmpibuf = stabilization_allocate_ibuf(NULL, ibuf, TRUE);
-
- /* scale would be handled by matrix transformation when angle is non-zero */
- if (tscale != 1.0f && tangle == 0.0f) {
- ImBuf *scaleibuf;
-
- stabilization_calculate_autoscale_factor(tracking, width, height);
-
- scaleibuf = stabilization_allocate_ibuf(stab->scaleibuf, ibuf, 0);
- stab->scaleibuf = scaleibuf;
-
- IMB_rectcpy(scaleibuf, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
- IMB_scalefastImBuf(scaleibuf, ibuf->x * tscale, ibuf->y * tscale);
+ /* Allocate frame for stabilization result. */
+ ibuf_flags = 0;
+ if (ibuf->rect)
+ ibuf_flags |= IB_rect;
+ if (ibuf->rect_float)
+ ibuf_flags |= IB_rectfloat;
- ibuf = scaleibuf;
- }
+ tmpibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, ibuf_flags);
+ /* Calculate stabilization matrix. */
+ BKE_tracking_stabilization_data_get(tracking, framenr, width, height, tloc, &tscale, &tangle);
BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
invert_m4(mat);
@@ -3627,7 +3590,7 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
* But need to keep an eye on this if the function will be
* used in other cases.
*/
- #pragma omp parallel for if(tmpibuf->y > 128)
+ #pragma omp parallel for if(tmpibuf->y > 128)
for (j = 0; j < tmpibuf->y; j++) {
int i;
for (i = 0; i < tmpibuf->x; i++) {
@@ -3639,6 +3602,7 @@ ImBuf *BKE_tracking_stabilize_frame(MovieTracking *tracking, int framenr, ImBuf
}
}
+ /* TODO(sergey): we've got no mipmaps actually? */
tmpibuf->userflags |= IB_MIPMAP_INVALID;
if (tmpibuf->rect_float)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3b9ae245661..fcd27e42c96 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6633,7 +6633,6 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
clip->tracking.stats = NULL;
clip->tracking.stabilization.ok = 0;
- clip->tracking.stabilization.scaleibuf = NULL;
clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track);
clip->tracking.dopesheet.ok = 0;
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 73cda070fd2..02c482096f6 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -205,8 +205,6 @@ typedef struct MovieTrackingStabilization {
/* some pre-computing run-time variables */
int ok; /* are precomputed values and scaled buf relevant? */
float scale; /* autoscale factor */
-
- struct ImBuf *scaleibuf; /* currently scaled ibuf */
} MovieTrackingStabilization;
typedef struct MovieTrackingReconstruction {