-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolour_filter_utils.hpp
64 lines (59 loc) · 935 Bytes
/
colour_filter_utils.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef COLOUR_FILTER_UTILS_HEADER
#define COLOUR_FILTER_UTILS_HEADER
int16_t ffv1(int16_t L,int16_t T,int16_t TL){
int16_t min = L;
int16_t max = T;
if(L > T){
min = T;
max = L;
}
if(TL >= max){
return min;
}
if(TL <= min){
return max;
}
return max - (TL - min);
}
uint16_t ffv1(uint16_t L,uint16_t T,uint16_t TL){
uint16_t min = L;
uint16_t max = T;
if(L > T){
min = T;
max = L;
}
if(TL >= max){
return min;
}
if(TL <= min){
return max;
}
return max - (TL - min);
}
uint16_t ffv1_16(uint16_t L,uint16_t T,uint16_t TL){
uint16_t min = L;
uint16_t max = T;
if(L > T){
min = T;
max = L;
}
if(TL >= max){
return min;
}
if(TL <= min){
return max;
}
return max - (TL - min);
}
uint16_t i_clamp(int16_t a,int16_t lower,int16_t upper){
if(a < lower){
return lower;
}
else if(a >= upper){
return upper - 1;
}
else{
return (int16_t)a;
}
}
#endif //COLOUR_FILTER_UTILS_HEADER