[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55901] trunk/blender/source/blender/ blenkernel/intern: Camera stabilization fixes and improvements
Sergey Sharybin
sergey.vfx at gmail.com
Mon Apr 8 12:56:51 CEST 2013
Revision: 55901
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55901
Author: nazgul
Date: 2013-04-08 10:56:50 +0000 (Mon, 08 Apr 2013)
Log Message:
-----------
Camera stabilization fixes and improvements
- Nearest interpolation was always used when there's
no rotation for stabilization. Was a failure of
optimization heuristic.
- Made 2d stabilization frame acquiring threaded.
This function is only used for display and sequencer
which will only benefit of threads here.
- Fixed bug introduced in r48749 which lead to
re-making stable frame on every redraw.
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48749
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/movieclip.c
trunk/blender/source/blender/blenkernel/intern/tracking.c
Modified: trunk/blender/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/movieclip.c 2013-04-08 10:03:51 UTC (rev 55900)
+++ trunk/blender/source/blender/blenkernel/intern/movieclip.c 2013-04-08 10:56:50 UTC (rev 55901)
@@ -973,6 +973,7 @@
copy_v2_v2(cache->stabilized.loc, tloc);
+ cache->stabilized.reference_ibuf = ibuf;
cache->stabilized.scale = tscale;
cache->stabilized.angle = tangle;
cache->stabilized.framenr = framenr;
Modified: trunk/blender/source/blender/blenkernel/intern/tracking.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/tracking.c 2013-04-08 10:03:51 UTC (rev 55900)
+++ trunk/blender/source/blender/blenkernel/intern/tracking.c 2013-04-08 10:56:50 UTC (rev 55901)
@@ -3564,6 +3564,9 @@
ImBuf *tmpibuf;
float width = ibuf->x, height = ibuf->y;
float aspect = tracking->camera.pixel_aspect;
+ float mat[4][4];
+ int j, filter = tracking->stabilization.filter;
+ void (*interpolation)(struct ImBuf *, struct ImBuf *, float, float, int, int) = NULL;
if (loc)
copy_v2_v2(tloc, loc);
@@ -3600,41 +3603,35 @@
ibuf = scaleibuf;
}
- if (tangle == 0.0f) {
- /* if angle is zero, then it's much faster to use rect copy
- * but could be issues with subpixel precisions
- */
- IMB_rectcpy(tmpibuf, ibuf,
- tloc[0] - (tscale - 1.0f) * width / 2.0f,
- tloc[1] - (tscale - 1.0f) * height / 2.0f,
- 0, 0, ibuf->x, ibuf->y);
- }
- else {
- float mat[4][4];
- int i, j, filter = tracking->stabilization.filter;
- void (*interpolation)(struct ImBuf *, struct ImBuf *, float, float, int, int) = NULL;
+ BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
+ invert_m4(mat);
- BKE_tracking_stabilization_data_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
- invert_m4(mat);
+ if (filter == TRACKING_FILTER_NEAREST)
+ interpolation = nearest_interpolation;
+ else if (filter == TRACKING_FILTER_BILINEAR)
+ interpolation = bilinear_interpolation;
+ else if (filter == TRACKING_FILTER_BICUBIC)
+ interpolation = bicubic_interpolation;
+ else
+ /* fallback to default interpolation method */
+ interpolation = nearest_interpolation;
- if (filter == TRACKING_FILTER_NEAREST)
- interpolation = nearest_interpolation;
- else if (filter == TRACKING_FILTER_BILINEAR)
- interpolation = bilinear_interpolation;
- else if (filter == TRACKING_FILTER_BICUBIC)
- interpolation = bicubic_interpolation;
- else
- /* fallback to default interpolation method */
- interpolation = nearest_interpolation;
+ /* This function is only used for display in clip editor and
+ * sequencer only, which would only benefit of using threads
+ * here.
+ *
+ * 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)
+ for (j = 0; j < tmpibuf->y; j++) {
+ int i;
+ for (i = 0; i < tmpibuf->x; i++) {
+ float vec[3] = {i, j, 0};
- for (j = 0; j < tmpibuf->y; j++) {
- for (i = 0; i < tmpibuf->x; i++) {
- float vec[3] = {i, j, 0};
+ mul_v3_m4v3(vec, mat, vec);
- mul_v3_m4v3(vec, mat, vec);
-
- interpolation(ibuf, tmpibuf, vec[0], vec[1], i, j);
- }
+ interpolation(ibuf, tmpibuf, vec[0], vec[1], i, j);
}
}
More information about the Bf-blender-cvs
mailing list