2D stabilization: flip orientation of the scale parameter

values > 1 will zoom in and values < 1 zoom out

Rationale: the changed orientation is more natural
from a user POV and doing it this way is also more
consistent with the calculation of the other
target_* parameters.

Compatibility: This will break *.blend files saved
with the previous version of this patch from the
last days (test period). It will *not* break any
old/migrated files: Previously, the DNA field "scale"
was only used to cache autoscale. Only with the
Stabilisator rework, "scale" becomes a first class
persistent DNA field. There is migration code to
init this field to 1.0
This commit is contained in:
Hermann Voßeler 2016-08-22 17:22:06 +02:00 committed by Sergey Sharybin
parent 95d3ca8bc6
commit 3dbe174440
3 changed files with 26 additions and 20 deletions

View File

@ -1020,13 +1020,13 @@ static void stabilization_calculate_data(StabContext *ctx,
float *r_scale,
float *r_angle)
{
float target_pos[2];
float target_pos[2], target_scale;
float scaleinf = get_animated_scaleinf(ctx, framenr);
*r_scale = get_animated_target_scale(ctx,framenr);
if (ctx->stab->flag & TRACKING_STABILIZE_SCALE) {
*r_scale *= expf(scale_step * scaleinf); /* Averaged in log scale */
*r_scale = expf(scale_step * scaleinf); /* Averaged in log scale */
} else {
*r_scale = 1.0f;
}
mul_v2_fl(r_translation, get_animated_locinf(ctx, framenr));
@ -1039,6 +1039,11 @@ static void stabilization_calculate_data(StabContext *ctx,
get_animated_target_pos(ctx, framenr, target_pos);
sub_v2_v2(r_translation, target_pos);
*r_angle -= get_animated_target_rot(ctx,framenr);
target_scale = get_animated_target_scale(ctx,framenr);
if (target_scale != 0.0f) {
*r_scale /= target_scale;
/* target_scale is an expected/intended reference zoom value*/
}
/* Convert from relative to absolute coordinates, square pixels. */
r_translation[0] *= (float)size * aspect;
@ -1194,9 +1199,9 @@ static void stabilization_determine_safe_image_area(StabContext *ctx,
J = G - E;
K = G * F - E * H;
S = (dx * I + dy * J + K) / (-w * I - h * J);
S = (-w * I - h * J) / (dx * I + dy * J + K);
scale = min_ff(scale, S);
scale = max_ff(scale, S);
}
}
}
@ -1205,7 +1210,7 @@ static void stabilization_determine_safe_image_area(StabContext *ctx,
stab->scale = scale;
if (stab->maxscale > 0.0f) {
stab->scale = max_ff(stab->scale, 1.0f / stab->maxscale);
stab->scale = min_ff(stab->scale, stab->maxscale);
}
}

View File

@ -91,9 +91,6 @@ static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabili
}
}
stab->rot_track = NULL; /* this field is now ignored */
/* by default show the track lists expanded, to improve "discoverability" */
stab->flag |= TRACKING_SHOW_STAB_TRACKS;
}
static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
@ -1369,13 +1366,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) {
if (clip->tracking.stabilization.rot_track) {
migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
if (!clip->tracking.stabilization.scale) {
/* ensure init.
* Was previously used for autoscale only,
* now used always (as "target scale") */
clip->tracking.stabilization.scale = 1.0f;
}
}
if (clip->tracking.stabilization.scale == 0.0f) {
/* ensure init.
* Was previously used for autoscale only,
* now used always (as "target scale") */
clip->tracking.stabilization.scale = 1.0f;
}
/* by default show the track lists expanded, to improve "discoverability" */
clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS;
/* deprecated, not used anymore */
clip->tracking.stabilization.ok = false;
}
}
}

View File

@ -1768,7 +1768,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
prop = RNA_def_property(srna, "target_rotation", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "target_rot");
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 10.0f, 3);
RNA_def_property_ui_text(prop, "Expected Rotation",
"Rotation present on original shot, will be compensated (e.g. for deliberate tilting)");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
@ -1776,9 +1776,9 @@ static void rna_def_trackingStabilization(BlenderRNA *brna)
/* target scale */
prop = RNA_def_property(srna, "target_zoom", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "scale");
RNA_def_property_range(prop, FLT_EPSILON, 100.0f);
RNA_def_property_ui_range(prop, 0.1f, 10.0f, 1, 3); /* increment in steps of 0.01. Show 3 digit after point */
RNA_def_property_ui_text(prop, "Expected Zoom",
RNA_def_property_range(prop, FLT_EPSILON, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.001f, 3); /* increment in steps of 0.001. Show 3 digit after point */
RNA_def_property_ui_text(prop, "Expected Scale",
"Explicitly scale resulting frame to compensate zoom of original shot");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate");