fix segv for plugin render_gui when plugin moved up/dn, opencv build fixes, opts...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / maskautos.C
index 04feb88de60e734af2d53ecde7e0515eeba9b288..bac0d851d965301f13508d3454e565a952d54f27 100644 (file)
@@ -22,6 +22,7 @@
 #include "automation.inc"
 #include "clip.h"
 #include "edl.h"
+#include "edlsession.h"
 #include "localsession.h"
 #include "maskauto.h"
 #include "maskautos.h"
@@ -50,7 +51,8 @@ void MaskAutos::update_parameter(MaskAuto *src)
 // Selection is always aligned to frame for masks
 
 // Create new keyframe if auto keyframes or replace entire keyframe.
-       if(selection_start == selection_end)
+       if( !edl->session->span_keyframes ||
+           EQUIV(selection_start, selection_end) )
        {
 // Search for keyframe to write to
                MaskAuto *dst = (MaskAuto*)get_auto_for_editing();
@@ -88,7 +90,7 @@ void MaskAutos::update_parameter(MaskAuto *src)
 
 
 
-void MaskAutos::get_points(ArrayList<MaskPoint*> *points,
+void MaskAutos::get_points(MaskPoints *points,
        int submask,
        int64_t position,
        int direction)
@@ -161,7 +163,7 @@ void MaskAutos::get_points(ArrayList<MaskPoint*> *points,
 }
 
 
-float MaskAutos::get_feather(int64_t position, int i, int direction)
+double MaskAutos::get_feather(int64_t position, int i, int direction)
 {
        Auto *begin = 0, *end = 0;
        position = (direction == PLAY_FORWARD) ? position : (position - 1);
@@ -172,11 +174,11 @@ float MaskAutos::get_feather(int64_t position, int i, int direction)
        double weight = end->position == begin->position ? 0.0 :
                (double)(position - begin->position) / (end->position - begin->position);
 
-       int result = prev_mask->feather * (1-weight) + next_mask->feather*weight + 0.5;
+       double result = prev_mask->feather * (1-weight) + next_mask->feather*weight;
        return result;
 }
 
-int MaskAutos::get_fader(int64_t position, int i, int direction)
+double MaskAutos::get_fader(int64_t position, int i, int direction)
 {
        Auto *begin = 0, *end = 0;
        position = (direction == PLAY_FORWARD) ? position : (position - 1);
@@ -187,7 +189,7 @@ int MaskAutos::get_fader(int64_t position, int i, int direction)
        double weight = end->position == begin->position ? 0.0 :
                (double)(position - begin->position) / (end->position - begin->position);
 
-       int result = prev_mask->fader * (1-weight) + next_mask->fader*weight + 0.5;
+       double result = prev_mask->fader * (1-weight) + next_mask->fader*weight;
 // printf("MaskAutos::get_fader %d %d %d %f %d %f %d\n", __LINE__, i,
 // ((MaskAuto*)begin)->fader, 1.0 - weight, ((MaskAuto*)end)->fader, weight, result);
        return result;
@@ -219,19 +221,18 @@ Auto* MaskAutos::new_auto()
        return new MaskAuto(edl, this);
 }
 
-void MaskAutos::dump()
+void MaskAutos::dump(FILE *fp)
 {
-       printf("        MaskAutos::dump %p\n", this);
-       printf("        Default: position %jd submasks %d\n",
+       fprintf(fp, "   MaskAutos::dump %p\n", this);
+       fprintf(fp, "   Default: position %jd submasks %d\n",
                default_auto->position,
                ((MaskAuto*)default_auto)->masks.total);
-       ((MaskAuto*)default_auto)->dump();
-       for(Auto* current = first; current; current = NEXT)
-       {
-               printf("        position %jd masks %d\n",
+       ((MaskAuto*)default_auto)->dump(fp);
+       for( Auto* current = first; current; current=NEXT ) {
+               fprintf(fp, "   position %jd masks %d\n",
                        current->position,
                        ((MaskAuto*)current)->masks.total);
-               ((MaskAuto*)current)->dump();
+               ((MaskAuto*)current)->dump(fp);
        }
 }
 
@@ -242,10 +243,7 @@ int MaskAutos::mask_exists(int64_t position, int direction)
 
        MaskAuto* keyframe = (MaskAuto*)get_prev_auto(position, direction, current);
 
-
-
-       for(int i = 0; i < keyframe->masks.total; i++)
-       {
+       for( int i = 0; i < keyframe->masks.total; i++ ) {
                SubMask *mask = keyframe->get_submask(i);
                if(mask->points.total > 1)
                        return 1;
@@ -256,12 +254,8 @@ int MaskAutos::mask_exists(int64_t position, int direction)
 int MaskAutos::total_submasks(int64_t position, int direction)
 {
        position = (direction == PLAY_FORWARD) ? position : (position - 1);
-       for(MaskAuto* current = (MaskAuto*)last;
-               current;
-               current = (MaskAuto*)PREVIOUS)
-       {
-               if(current->position <= position)
-               {
+       for( MaskAuto* current=(MaskAuto*)last; current; current=(MaskAuto*)PREVIOUS ) {
+               if( current->position <= position ) {
                        return current->masks.total;
                }
        }
@@ -273,10 +267,7 @@ int MaskAutos::total_submasks(int64_t position, int direction)
 void MaskAutos::translate_masks(float translate_x, float translate_y)
 {
        ((MaskAuto *)default_auto)->translate_submasks(translate_x, translate_y);
-       for(MaskAuto* current = (MaskAuto*)first;
-               current;
-               current = (MaskAuto*)NEXT)
-       {
+       for( MaskAuto* current=(MaskAuto*)first; current; current=(MaskAuto*)NEXT ) {
                current->translate_submasks(translate_x, translate_y);
        }
 }