X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmaskautos.C;h=3e736f1e73bad75b961fa1f327e338d051502cde;hb=9c8644d5f3f05b52a81c259c32217bcd57792ae5;hp=843d76ee3cd75da64e75a38c2adc67287b3acb1f;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/maskautos.C b/cinelerra-5.1/cinelerra/maskautos.C index 843d76ee..3e736f1e 100644 --- a/cinelerra-5.1/cinelerra/maskautos.C +++ b/cinelerra-5.1/cinelerra/maskautos.C @@ -161,59 +161,46 @@ void MaskAutos::get_points(ArrayList *points, } -float MaskAutos::get_feather(int64_t position, 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); + MaskAuto*prev = (MaskAuto*)get_prev_auto(position, PLAY_FORWARD, begin, 1); + MaskAuto*next = (MaskAuto*)get_next_auto(position, PLAY_FORWARD, end, 1); + SubMask *prev_mask = prev->get_submask(i), *next_mask = next->get_submask(i); - get_prev_auto(position, PLAY_FORWARD, begin, 1); - get_next_auto(position, PLAY_FORWARD, end, 1); + double weight = end->position == begin->position ? 0.0 : + (double)(position - begin->position) / (end->position - begin->position); - double weight = 0.0; - if(end->position != begin->position) - weight = (double)(position - begin->position) / (end->position - begin->position); - - return ((MaskAuto*)begin)->feather * (1.0 - weight) + ((MaskAuto*)end)->feather * weight; + double result = prev_mask->feather * (1-weight) + next_mask->feather*weight; + return result; } -int MaskAutos::get_value(int64_t position, 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); + MaskAuto*prev = (MaskAuto*)get_prev_auto(position, PLAY_FORWARD, begin, 1); + MaskAuto*next = (MaskAuto*)get_next_auto(position, PLAY_FORWARD, end, 1); + SubMask *prev_mask = prev->get_submask(i), *next_mask = next->get_submask(i); + + double weight = end->position == begin->position ? 0.0 : + (double)(position - begin->position) / (end->position - begin->position); - get_prev_auto(position, PLAY_FORWARD, begin, 1); - get_next_auto(position, PLAY_FORWARD, end, 1); - - double weight = 0.0; - if(end->position != begin->position) - weight = (double)(position - begin->position) / (end->position - begin->position); - - int result = (int)((double)((MaskAuto*)begin)->value * (1.0 - weight) + - (double)((MaskAuto*)end)->value * weight + 0.5); -// printf("MaskAutos::get_value %d %d %f %d %f %d\n", -// __LINE__, -// ((MaskAuto*)begin)->value, -// 1.0 - weight, -// ((MaskAuto*)end)->value, -// weight, -// result); + 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; } -void MaskAutos::avg_points(MaskPoint *output, - MaskPoint *input1, - MaskPoint *input2, - int64_t output_position, - int64_t position1, - int64_t position2) +void MaskAutos::avg_points(MaskPoint *output, MaskPoint *input1, MaskPoint *input2, + int64_t output_position, int64_t position1, int64_t position2) { - if(position2 == position1) - { + if(position2 == position1) { *output = *input1; } - else - { + else { float fraction2 = (float)(output_position - position1) / (position2 - position1); float fraction1 = 1 - fraction2; output->x = input1->x * fraction1 + input2->x * fraction2; @@ -232,19 +219,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); } } @@ -255,10 +241,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; @@ -269,12 +252,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; } } @@ -286,10 +265,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); } }