factor out sqrt many million per sec
This commit is contained in:
parent
91d62b7cc6
commit
16656b5b17
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue