]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
factor out sqrt many million per sec
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 27 Feb 2017 17:01:56 +0000 (11:01 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 27 Feb 2017 17:01:56 +0000 (11:01 -0600)
src/mod/applications/mod_video_filter/mod_video_filter.c
src/switch_core_video.c

index 5c8b08c82fd38f8ca75ea059ded90737558485a3..5a11988ace546c5407ff61b9deb7cf81f4e46660 100644 (file)
@@ -108,7 +108,7 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char
                        
                        switch_color_set_rgb(&context->mask[j], list[j]);
                        if (thresh) {
-                               context->thresholds[j] = thresh;
+                               context->thresholds[j] = thresh*thresh;
                        }
                        context->mask_len++;
                }
@@ -121,7 +121,7 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char
                int j;
 
                if (thresh > 0) {
-                       context->threshold = thresh;
+                       context->threshold = thresh * thresh;
 
                        for (j = 0; j < context->mask_len; j++) {
                                if (!context->thresholds[j]) context->thresholds[j] = context->threshold;
index 401e97997a2cbd783aa6bd36ef025da28925077b..052ad98f674f5ba8eab389a57a88cf79cf09acdf 100644 (file)
@@ -768,13 +768,13 @@ static inline int switch_color_distance(switch_rgb_color_t *c1, switch_rgb_color
        cg2 = c1->g/2 - c2->g/2;
        cb2 = c1->b/2 - c2->b/2;
 
-       a = sqrt((2*cr*cr) + (4*cg*cg) + (3*cb*cb));
-       b = sqrt((2*cr2*cr2) + (4*cg2*cg2) + (3*cb2*cb2));
+       a = ((2*cr*cr) + (4*cg*cg) + (3*cb*cb));
+       b = ((2*cr2*cr2) + (4*cg2*cg2) + (3*cb2*cb2));
 
        aa = (int)a;
-       bb = (int)b*5;
+       bb = (int)b*25;
 
-       r = (((bb*2)+(aa))/3)/10;
+       r = (((bb*4)+(aa))/9)/100;
 
        return r;