include/avs/minmax.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This program is free software; you can redistribute it and/or modify | ||
| 2 | // it under the terms of the GNU General Public License as published by | ||
| 3 | // the Free Software Foundation; either version 2 of the License, or | ||
| 4 | // (at your option) any later version. | ||
| 5 | // | ||
| 6 | // This program is distributed in the hope that it will be useful, | ||
| 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | // GNU General Public License for more details. | ||
| 10 | // | ||
| 11 | // You should have received a copy of the GNU General Public License | ||
| 12 | // along with this program; if not, write to the Free Software | ||
| 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | ||
| 14 | // http://www.gnu.org/copyleft/gpl.html . | ||
| 15 | // | ||
| 16 | // Linking Avisynth statically or dynamically with other modules is making a | ||
| 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU | ||
| 18 | // General Public License cover the whole combination. | ||
| 19 | // | ||
| 20 | // As a special exception, the copyright holders of Avisynth give you | ||
| 21 | // permission to link Avisynth with independent modules that communicate with | ||
| 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license | ||
| 23 | // terms of these independent modules, and to copy and distribute the | ||
| 24 | // resulting combined work under terms of your choice, provided that | ||
| 25 | // every copy of the combined work is accompanied by a complete copy of | ||
| 26 | // the source code of Avisynth (the version of Avisynth used to produce the | ||
| 27 | // combined work), being distributed under the terms of the GNU General | ||
| 28 | // Public License plus this exception. An independent module is a module | ||
| 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, | ||
| 30 | // import and export plugins, or graphical user interfaces. | ||
| 31 | |||
| 32 | #ifndef AVSCORE_MINMAX_H | ||
| 33 | #define AVSCORE_MINMAX_H | ||
| 34 | |||
| 35 | template<typename T> | ||
| 36 | 69163 | T min(T v1, T v2) | |
| 37 | { | ||
| 38 |
8/14double min<double>(double, double):
✓ Branch 2 → 3 taken 4 times.
✗ Branch 2 → 4 not taken.
float min<float>(float, float):
✓ Branch 2 → 3 taken 9 times.
✓ Branch 2 → 4 taken 12 times.
unsigned char min<unsigned char>(unsigned char, unsigned char):
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
int min<int>(int, int):
✓ Branch 2 → 3 taken 937 times.
✓ Branch 2 → 4 taken 67283 times.
unsigned int min<unsigned int>(unsigned int, unsigned int):
✓ Branch 2 → 3 taken 11 times.
✓ Branch 2 → 4 taken 1 time.
long min<long>(long, long):
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
unsigned long min<unsigned long>(unsigned long, unsigned long):
✓ Branch 2 → 3 taken 906 times.
✗ Branch 2 → 4 not taken.
|
69163 | return v1 < v2 ? v1 : v2; |
| 39 | } | ||
| 40 | |||
| 41 | template<typename T> | ||
| 42 | 19351 | T max(T v1, T v2) | |
| 43 | { | ||
| 44 |
11/12double max<double>(double, double):
✓ Branch 2 → 3 taken 16386 times.
✓ Branch 2 → 4 taken 2 times.
float max<float>(float, float):
✓ Branch 2 → 3 taken 12 times.
✓ Branch 2 → 4 taken 9 times.
int max<int>(int, int):
✓ Branch 2 → 3 taken 334 times.
✓ Branch 2 → 4 taken 1127 times.
unsigned int max<unsigned int>(unsigned int, unsigned int):
✓ Branch 2 → 3 taken 5 times.
✓ Branch 2 → 4 taken 763 times.
long max<long>(long, long):
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 6 times.
unsigned long max<unsigned long>(unsigned long, unsigned long):
✓ Branch 2 → 3 taken 702 times.
✓ Branch 2 → 4 taken 5 times.
|
19351 | return v1 > v2 ? v1 : v2; |
| 45 | } | ||
| 46 | |||
| 47 | template<typename T> | ||
| 48 | 1128974 | T clamp(T n, T min, T max) | |
| 49 | { | ||
| 50 |
9/12double clamp<double>(double, double, double):
✓ Branch 2 → 3 taken 23714 times.
✓ Branch 2 → 4 taken 702619 times.
float clamp<float>(float, float, float):
✓ Branch 2 → 3 taken 18 times.
✓ Branch 2 → 4 taken 228 times.
int clamp<int>(int, int, int):
✓ Branch 2 → 3 taken 4875 times.
✓ Branch 2 → 4 taken 397055 times.
long clamp<long>(long, long, long):
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 4 taken 10 times.
unsigned long clamp<unsigned long>(unsigned long, unsigned long, unsigned long):
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 453 times.
unsigned short clamp<unsigned short>(unsigned short, unsigned short, unsigned short):
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
|
1128974 | n = n > max ? max : n; |
| 51 |
9/12double clamp<double>(double, double, double):
✓ Branch 5 → 6 taken 10889 times.
✓ Branch 5 → 7 taken 715444 times.
float clamp<float>(float, float, float):
✓ Branch 5 → 6 taken 4 times.
✓ Branch 5 → 7 taken 242 times.
int clamp<int>(int, int, int):
✓ Branch 5 → 6 taken 8411 times.
✓ Branch 5 → 7 taken 393519 times.
long clamp<long>(long, long, long):
✓ Branch 5 → 6 taken 2 times.
✓ Branch 5 → 7 taken 10 times.
unsigned long clamp<unsigned long>(unsigned long, unsigned long, unsigned long):
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 453 times.
unsigned short clamp<unsigned short>(unsigned short, unsigned short, unsigned short):
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
|
1128974 | return n < min ? min : n; |
| 52 | } | ||
| 53 | |||
| 54 | #endif // AVSCORE_MINMAX_H | ||
| 55 |