X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmaskautos.C;h=04feb88de60e734af2d53ecde7e0515eeba9b288;hp=62b6ad74ea9d8d7d8253502abbcf89969104b3f3;hb=7ead9f7382846e81c2f8efb25780014e5f8834c3;hpb=2f5f5847bfeea491f69f5314dcbccaf6de4b22e4 diff --git a/cinelerra-5.1/cinelerra/maskautos.C b/cinelerra-5.1/cinelerra/maskautos.C index 62b6ad74..04feb88d 100644 --- a/cinelerra-5.1/cinelerra/maskautos.C +++ b/cinelerra-5.1/cinelerra/maskautos.C @@ -161,37 +161,35 @@ void MaskAutos::get_points(ArrayList *points, } -float MaskAutos::get_feather(int64_t position, int direction) +float 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; + int result = prev_mask->feather * (1-weight) + next_mask->feather*weight + 0.5; + return result; } -int MaskAutos::get_value(int64_t position, int direction) +int 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); - 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); + double weight = end->position == begin->position ? 0.0 : + (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); + int result = prev_mask->fader * (1-weight) + next_mask->fader*weight + 0.5; +// 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; }