[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44151] branches/soc-2011-tomato/source/ blender: Tomato: run aspect correction before stabilizing shot.
Sergey Sharybin
sergey.vfx at gmail.com
Thu Feb 16 16:03:24 CET 2012
Revision: 44151
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44151
Author: nazgul
Date: 2012-02-16 15:03:18 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
Tomato: run aspect correction before stabilizing shot.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2012-02-16 13:23:36 UTC (rev 44150)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2012-02-16 15:03:18 UTC (rev 44151)
@@ -138,7 +138,7 @@
/* 2D stabilization */
void BKE_tracking_stabilization_data(struct MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale, float *angle);
struct ImBuf *BKE_tracking_stabilize(struct MovieTracking *tracking, int framenr, struct ImBuf *ibuf, float loc[2], float *scale, float *angle);
-void BKE_tracking_stabdata_to_mat4(int width, int height, float loc[2], float scale, float angle, float mat[4][4]);
+void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, float loc[2], float scale, float angle, float mat[4][4]);
/* Distortion/Undistortion */
void BKE_tracking_apply_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2012-02-16 13:23:36 UTC (rev 44150)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2012-02-16 15:03:18 UTC (rev 44151)
@@ -279,7 +279,7 @@
int framenr;
int postprocess_flag;
- float loc[2], scale, angle;
+ float loc[2], scale, angle, aspect;
int proxy;
short render_flag;
} stabilized;
@@ -727,6 +727,10 @@
if(cache->stabilized.postprocess_flag != postprocess_flag)
return NULL;
+ /* stabilization also depends on pixel aspect ratio */
+ if(cache->stabilized.aspect != clip->tracking.camera.pixel_aspect)
+ return NULL;
+
stableibuf = cache->stabilized.ibuf;
BKE_tracking_stabilization_data(&clip->tracking, framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
@@ -763,6 +767,7 @@
cache->stabilized.scale = tscale;
cache->stabilized.angle = tangle;
cache->stabilized.framenr = framenr;
+ cache->stabilized.aspect = clip->tracking.camera.pixel_aspect;
if(clip->flag&MCLIP_USE_PROXY) {
cache->stabilized.proxy= rendersize_to_proxy(user, clip->flag);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2012-02-16 13:23:36 UTC (rev 44150)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2012-02-16 15:03:18 UTC (rev 44151)
@@ -2485,6 +2485,7 @@
{
float firstmedian[2];
MovieTrackingStabilization *stab= &tracking->stabilization;
+ float aspect= tracking->camera.pixel_aspect;
if(stab->ok)
return stab->scale;
@@ -2535,7 +2536,7 @@
float mat[4][4];
float points[4][2]={{0.0f, 0.0f}, {0.0f, height}, {width, height}, {width, 0.0f}};
- BKE_tracking_stabdata_to_mat4(width, height, loc, scale, angle, mat);
+ BKE_tracking_stabdata_to_mat4(width, height, aspect, loc, scale, angle, mat);
for(i= 0; i<4; i++) {
int j;
@@ -2650,6 +2651,7 @@
MovieTrackingStabilization *stab= &tracking->stabilization;
ImBuf *tmpibuf;
float width= ibuf->x, height= ibuf->y;
+ float aspect= tracking->camera.pixel_aspect;
if(loc) copy_v2_v2(tloc, loc);
if(scale) tscale= *scale;
@@ -2688,7 +2690,7 @@
float mat[4][4];
int i, j;
- BKE_tracking_stabdata_to_mat4(ibuf->x, ibuf->y, tloc, tscale, tangle, mat);
+ BKE_tracking_stabdata_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
invert_m4(mat);
for(j=0; j<tmpibuf->y; j++) {
@@ -2715,16 +2717,21 @@
return tmpibuf;
}
-void BKE_tracking_stabdata_to_mat4(int width, int height, float loc[2], float scale, float angle, float mat[4][4])
+void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, float loc[2], float scale, float angle, float mat[4][4])
{
- float lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4];
+ float lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4], amat[4][4], iamat[4][4];
float svec[3]= {scale, scale, scale};
unit_m4(rmat);
unit_m4(lmat);
unit_m4(smat);
unit_m4(cmat);
+ unit_m4(amat);
+ /* aspect ratio correction matrix */
+ amat[0][0] = 1.0f / aspect;
+ invert_m4_m4(iamat, amat);
+
/* image center as rotation center */
cmat[3][0]= (float)width/2.0f;
cmat[3][1]= (float)height/2.0f;
@@ -2735,7 +2742,7 @@
rotate_m4(rmat, 'Z', angle); /* rotation matrix */
/* compose transformation matrix */
- mul_serie_m4(mat, lmat, cmat, rmat, smat, icmat, NULL, NULL, NULL);
+ mul_serie_m4(mat, amat, lmat, cmat, rmat, smat, icmat, iamat, NULL);
}
MovieDistortion *BKE_tracking_distortion_create(void)
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2012-02-16 13:23:36 UTC (rev 44150)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2012-02-16 15:03:18 UTC (rev 44151)
@@ -1289,13 +1289,14 @@
if(ibuf) {
float loc[2];
+ float aspect= clip->tracking.camera.pixel_aspect;
if(width != ibuf->x)
mul_v2_v2fl(loc, sc->loc, (float)width / ibuf->x);
else
copy_v2_v2(loc, sc->loc);
- BKE_tracking_stabdata_to_mat4(width, height, loc, sc->scale, sc->angle, sc->stabmat);
+ BKE_tracking_stabdata_to_mat4(width, height, aspect, loc, sc->scale, sc->angle, sc->stabmat);
unit_m4(smat);
smat[0][0]= 1.0f/width;
More information about the Bf-blender-cvs
mailing list