[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44152] branches/soc-2011-tomato: Tomato: configurable filter type for 2d stabilization
Sergey Sharybin
sergey.vfx at gmail.com
Thu Feb 16 16:03:38 CET 2012
Revision: 44152
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44152
Author: nazgul
Date: 2012-02-16 15:03:37 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
Tomato: configurable filter type for 2d stabilization
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
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/makesdna/DNA_tracking_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2012-02-16 15:03:18 UTC (rev 44151)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2012-02-16 15:03:37 UTC (rev 44152)
@@ -686,7 +686,9 @@
row.active = stab.rotation_track is not None
row.prop(stab, "influence_rotation")
+ layout.prop(stab, "filter_type")
+
class CLIP_PT_marker(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2012-02-16 15:03:18 UTC (rev 44151)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2012-02-16 15:03:37 UTC (rev 44152)
@@ -280,7 +280,7 @@
int postprocess_flag;
float loc[2], scale, angle, aspect;
- int proxy;
+ int proxy, filter;
short render_flag;
} stabilized;
} MovieClipCache;
@@ -706,6 +706,7 @@
static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr, int postprocess_flag)
{
MovieClipCache *cache = clip->cache;
+ MovieTracking *tracking = &clip->tracking;
ImBuf *stableibuf;
float tloc[2], tscale, tangle;
short proxy = IMB_PROXY_NONE;
@@ -728,9 +729,12 @@
return NULL;
/* stabilization also depends on pixel aspect ratio */
- if(cache->stabilized.aspect != clip->tracking.camera.pixel_aspect)
+ if(cache->stabilized.aspect != tracking->camera.pixel_aspect)
return NULL;
+ if(cache->stabilized.filter != tracking->stabilization.filter)
+ return NULL;
+
stableibuf = cache->stabilized.ibuf;
BKE_tracking_stabilization_data(&clip->tracking, framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
@@ -752,6 +756,7 @@
int framenr, int postprocess_flag)
{
MovieClipCache *cache = clip->cache;
+ MovieTracking *tracking = &clip->tracking;
ImBuf *stableibuf;
float tloc[2], tscale, tangle;
@@ -767,7 +772,8 @@
cache->stabilized.scale = tscale;
cache->stabilized.angle = tangle;
cache->stabilized.framenr = framenr;
- cache->stabilized.aspect = clip->tracking.camera.pixel_aspect;
+ cache->stabilized.aspect = tracking->camera.pixel_aspect;
+ cache->stabilized.filter = tracking->stabilization.filter;
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 15:03:18 UTC (rev 44151)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2012-02-16 15:03:37 UTC (rev 44152)
@@ -2688,19 +2688,26 @@
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;
+ int i, j, filter= tracking->stabilization.filter;
+ void (*interpolation) (struct ImBuf*, struct ImBuf*, float, float, int, int) = NULL;
BKE_tracking_stabdata_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
invert_m4(mat);
+ if(filter == TRACKING_FILTER_NEAREAST)
+ interpolation = neareast_interpolation;
+ else if(filter == TRACKING_FILTER_BILINEAR)
+ interpolation = bilinear_interpolation;
+ else if(filter == TRACKING_FILTER_BICUBIC)
+ interpolation = bicubic_interpolation;
+
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);
- /* TODO: add selector for interpolation method */
- neareast_interpolation(ibuf, tmpibuf, vec[0], vec[1], i, j);
+ interpolation(ibuf, tmpibuf, vec[0], vec[1], i, j);
}
}
}
Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h 2012-02-16 15:03:18 UTC (rev 44151)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h 2012-02-16 15:03:37 UTC (rev 44152)
@@ -159,8 +159,10 @@
float locinf, scaleinf, rotinf; /* influence on location, scale and rotation */
+ int filter; /* filter used for pixel interpolation */
+
/* some pre-computing run-time variables */
- int ok, pad; /* are precomputed values and scaled buf relevant? */
+ int ok; /* are precomputed values and scaled buf relevant? */
float scale; /* autoscale factor */
struct ImBuf *scaleibuf; /* currently scaled ibuf */
@@ -258,6 +260,11 @@
#define TRACKING_AUTOSCALE (1<<1)
#define TRACKING_STABILIZE_ROTATION (1<<2)
+/* MovieTrackingStrabilization->filter */
+#define TRACKING_FILTER_NEAREAST 0
+#define TRACKING_FILTER_BILINEAR 1
+#define TRACKING_FILTER_BICUBIC 2
+
/* MovieTrackingReconstruction->flag */
#define TRACKING_RECONSTRUCTED (1<<0)
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2012-02-16 15:03:18 UTC (rev 44151)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c 2012-02-16 15:03:37 UTC (rev 44152)
@@ -1064,6 +1064,12 @@
StructRNA *srna;
PropertyRNA *prop;
+ static EnumPropertyItem filter_items[] = {
+ {TRACKING_FILTER_NEAREAST, "NEAREST", 0, "Nearest", ""},
+ {TRACKING_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", ""},
+ {TRACKING_FILTER_BICUBIC, "BICUBIC", 0, "Bicubic", ""},
+ {0, NULL, 0, NULL, NULL}};
+
srna= RNA_def_struct(brna, "MovieTrackingStabilization", NULL);
RNA_def_struct_path_func(srna, "rna_trackingStabilization_path");
RNA_def_struct_ui_text(srna, "Movie tracking stabilization data", "Match-moving stabilization data for tracking");
@@ -1137,6 +1143,13 @@
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Rotation Influence", "Influence of stabilization algorithm on footage rotation");
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
+
+ /* filter */
+ prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "filter");
+ RNA_def_property_enum_items(prop, filter_items);
+ RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization");
+ RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
}
static void rna_def_reconstructedCamera(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list