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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-02-17 12:27:19 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-02-17 12:27:19 +0400
commited3b7e2c23ca50eb67e63caec0c88197f59b2573 (patch)
treec614e23685d9ab93d9c6e7ec04e5b0463afea002
parentfdeca277fdfab889279c0a4a3b7b1935ff0121fa (diff)
parent62d09c9103f07c86c484d2a044a8884c337a92a3 (diff)
Camera tracking: configurable filter type for 2d stabilization
-- svn merge -r44151:44152 ^/branches/soc-2011-tomato
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c12
-rw-r--r--source/blender/blenkernel/intern/tracking.c13
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h9
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c13
5 files changed, 42 insertions, 7 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index eb97e546379..b8a205dc662 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -684,6 +684,8 @@ class CLIP_PT_stabilization(Panel):
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'
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index ce0d169557d..69b32ce46f8 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -280,7 +280,7 @@ typedef struct MovieClipCache {
int postprocess_flag;
float loc[2], scale, angle, aspect;
- int proxy;
+ int proxy, filter;
short render_flag;
} stabilized;
} MovieClipCache;
@@ -706,6 +706,7 @@ ImBuf *BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user
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,7 +729,10 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
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;
@@ -752,6 +756,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
int framenr, int postprocess_flag)
{
MovieClipCache *cache = clip->cache;
+ MovieTracking *tracking = &clip->tracking;
ImBuf *stableibuf;
float tloc[2], tscale, tangle;
@@ -767,7 +772,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
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);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 04766910df6..7461e057df5 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -2688,19 +2688,26 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
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);
}
}
}
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 1b41131c07d..e81344d7d51 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -159,8 +159,10 @@ typedef struct MovieTrackingStabilization {
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 @@ enum {
#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)
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 2d6a568c79d..e4ce7304577 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -1064,6 +1064,12 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
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 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
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)