1*77c1e3ccSAndroid Build Coastguard Worker // Copyright (c) 2006, 2008 Edward Rosten
2*77c1e3ccSAndroid Build Coastguard Worker // All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker //
4*77c1e3ccSAndroid Build Coastguard Worker // Redistribution and use in source and binary forms, with or without
5*77c1e3ccSAndroid Build Coastguard Worker // modification, are permitted provided that the following conditions
6*77c1e3ccSAndroid Build Coastguard Worker // are met:
7*77c1e3ccSAndroid Build Coastguard Worker //
8*77c1e3ccSAndroid Build Coastguard Worker // *Redistributions of source code must retain the above copyright
9*77c1e3ccSAndroid Build Coastguard Worker // notice, this list of conditions and the following disclaimer.
10*77c1e3ccSAndroid Build Coastguard Worker //
11*77c1e3ccSAndroid Build Coastguard Worker // *Redistributions in binary form must reproduce the above copyright
12*77c1e3ccSAndroid Build Coastguard Worker // notice, this list of conditions and the following disclaimer in the
13*77c1e3ccSAndroid Build Coastguard Worker // documentation and/or other materials provided with the distribution.
14*77c1e3ccSAndroid Build Coastguard Worker //
15*77c1e3ccSAndroid Build Coastguard Worker // *Neither the name of the University of Cambridge nor the names of
16*77c1e3ccSAndroid Build Coastguard Worker // its contributors may be used to endorse or promote products derived
17*77c1e3ccSAndroid Build Coastguard Worker // from this software without specific prior written permission.
18*77c1e3ccSAndroid Build Coastguard Worker //
19*77c1e3ccSAndroid Build Coastguard Worker // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20*77c1e3ccSAndroid Build Coastguard Worker // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21*77c1e3ccSAndroid Build Coastguard Worker // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22*77c1e3ccSAndroid Build Coastguard Worker // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23*77c1e3ccSAndroid Build Coastguard Worker // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24*77c1e3ccSAndroid Build Coastguard Worker // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25*77c1e3ccSAndroid Build Coastguard Worker // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26*77c1e3ccSAndroid Build Coastguard Worker // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27*77c1e3ccSAndroid Build Coastguard Worker // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28*77c1e3ccSAndroid Build Coastguard Worker // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29*77c1e3ccSAndroid Build Coastguard Worker // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*77c1e3ccSAndroid Build Coastguard Worker
31*77c1e3ccSAndroid Build Coastguard Worker // clang-format off
32*77c1e3ccSAndroid Build Coastguard Worker #include <stdlib.h>
33*77c1e3ccSAndroid Build Coastguard Worker #include "fast.h"
34*77c1e3ccSAndroid Build Coastguard Worker
35*77c1e3ccSAndroid Build Coastguard Worker
aom_fast9_detect_nonmax(const byte * im,int xsize,int ysize,int stride,int b,int ** ret_scores,int * ret_num_corners)36*77c1e3ccSAndroid Build Coastguard Worker xy* aom_fast9_detect_nonmax(const byte* im, int xsize, int ysize, int stride, int b,
37*77c1e3ccSAndroid Build Coastguard Worker int** ret_scores, int* ret_num_corners)
38*77c1e3ccSAndroid Build Coastguard Worker {
39*77c1e3ccSAndroid Build Coastguard Worker xy* corners;
40*77c1e3ccSAndroid Build Coastguard Worker int num_corners;
41*77c1e3ccSAndroid Build Coastguard Worker int* scores;
42*77c1e3ccSAndroid Build Coastguard Worker xy* nonmax;
43*77c1e3ccSAndroid Build Coastguard Worker
44*77c1e3ccSAndroid Build Coastguard Worker corners = aom_fast9_detect(im, xsize, ysize, stride, b, &num_corners);
45*77c1e3ccSAndroid Build Coastguard Worker if(!corners)
46*77c1e3ccSAndroid Build Coastguard Worker {
47*77c1e3ccSAndroid Build Coastguard Worker // Memory allocation failure
48*77c1e3ccSAndroid Build Coastguard Worker *ret_num_corners = -1;
49*77c1e3ccSAndroid Build Coastguard Worker return NULL;
50*77c1e3ccSAndroid Build Coastguard Worker }
51*77c1e3ccSAndroid Build Coastguard Worker // num_corners may be zero.
52*77c1e3ccSAndroid Build Coastguard Worker scores = aom_fast9_score(im, stride, corners, num_corners, b);
53*77c1e3ccSAndroid Build Coastguard Worker if(!scores && num_corners > 0)
54*77c1e3ccSAndroid Build Coastguard Worker {
55*77c1e3ccSAndroid Build Coastguard Worker // Memory allocation failure
56*77c1e3ccSAndroid Build Coastguard Worker free(corners);
57*77c1e3ccSAndroid Build Coastguard Worker *ret_num_corners = -1;
58*77c1e3ccSAndroid Build Coastguard Worker return NULL;
59*77c1e3ccSAndroid Build Coastguard Worker }
60*77c1e3ccSAndroid Build Coastguard Worker nonmax = aom_nonmax_suppression(corners, scores, num_corners, ret_scores, ret_num_corners);
61*77c1e3ccSAndroid Build Coastguard Worker
62*77c1e3ccSAndroid Build Coastguard Worker free(corners);
63*77c1e3ccSAndroid Build Coastguard Worker free(scores);
64*77c1e3ccSAndroid Build Coastguard Worker
65*77c1e3ccSAndroid Build Coastguard Worker return nonmax;
66*77c1e3ccSAndroid Build Coastguard Worker }
67*77c1e3ccSAndroid Build Coastguard Worker // clang-format on
68