Mask off large constants for RV32
[riscv-tests.git] / benchmarks / median / median.c
1 // See LICENSE for license details.
2
3 //**************************************************************************
4 // Median filter (c version)
5 //--------------------------------------------------------------------------
6
7 void median( int n, int input[], int results[] )
8 {
9 int A, B, C, i;
10
11 // Zero the ends
12 results[0] = 0;
13 results[n-1] = 0;
14
15 // Do the filter
16 for ( i = 1; i < (n-1); i++ ) {
17
18 A = input[i-1];
19 B = input[i];
20 C = input[i+1];
21
22 if ( A < B ) {
23 if ( B < C )
24 results[i] = B;
25 else if ( C < A )
26 results[i] = A;
27 else
28 results[i] = C;
29 }
30
31 else {
32 if ( A < C )
33 results[i] = A;
34 else if ( C < B )
35 results[i] = B;
36 else
37 results[i] = C;
38 }
39
40 }
41
42 }