/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dict_hw/src/normxcorr_hw.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-12-12 01:38:41 UTC
  • Revision ID: csa@dside.dyndns.org-20091212013841-feih3qa4i28x75j4
Provide stand-alone library

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef NORMXCORR_HW_H
2
2
#define NORMXCORR_HW_H
3
 
 
4
 
#if defined(_WIN32) || defined(_WIN64)
5
 
# include <windows.h>
6
 
    typedef UINT8 uint8_t;
7
 
    typedef UINT16 uint16_t;
8
 
    typedef UINT32 uint32_t;
9
 
    typedef INT8 int8_t;
10
 
    typedef INT16 int16_t;
11
 
    typedef INT32 int32_t;
12
 
#else
13
 
# include <stdint.h>
14
 
#endif
15
 
 
16
 
#include <mex.h>
17
 
 
18
3
#include <cuda.h>
19
4
#include <cuda_runtime.h>
20
5
 
30
15
#define CP_BLOCK_SIZE BLOCK_SIZE_2D
31
16
#define SIDE_BLOCK_SIZE BLOCK_SIZE_2D
32
17
 
33
 
 
34
 
//#define VALIDATE_LSUM
35
 
//#define VALIDATE_PEAK
36
18
#define USE_UNDOCUMENTED
37
19
 
38
 
typedef enum {
39
 
    ACTION_SETUP = 1,
40
 
#ifdef VALIDATE_LSUM
41
 
    ACTION_COMPUTE_BASE_FRAGMENT = 2,
42
 
#endif /* VALIDAT_LSUM */
43
 
    ACTION_SET_BASE_POINTS = 3,
44
 
    ACTION_COMPUTE_BASE = 4,
45
 
    ACTION_PREPARE = 5,
46
 
#ifdef VALIDATE_PEAK
47
 
    ACTION_COMPUTE_FRAGMENT = 11,
48
 
    ACTION_GET_CORRECTIONS = 15,
49
 
#endif /* VALIDATE_PEAK */
50
 
    ACTION_SET_POINTS = 12,
51
 
    ACTION_COMPUTE = 13,
52
 
    ACTION_GET_POINTS = 14,
53
 
} TAction;
54
 
 
55
 
typedef enum {
56
 
    ERROR_CUFFT = 1,
57
 
    ERROR_CUDA_MALLOC = 2,
58
 
    ERROR_MALLOC = 3,
59
 
    ERROR_CUDPP = 4
60
 
} TError;
61
 
 
62
20
struct STProcessingState {
63
21
    int stored;                         // flag indicating if we already have coordinates in coords stored
64
22
 
65
 
    uint8_t *banlist;                   // control points banned from computations for various reasons
 
23
    unsigned char *banlist;             // control points banned from computations for various reasons
66
24
 
67
 
    mxArray *coords;                    // Matlab array with current coordinates
68
25
 
69
26
    float *points;                      // various information on control points
70
27
                                        //      base_x, base_y, data_x, data_y
78
35
                                        // 2: sum
79
36
                                        // 3: denom
80
37
 
81
 
    uint8_t *input_buffer;              // Input Image buffer / Host
82
 
    uint8_t *cuda_input_buffer;         // Input Image buffer / Device
 
38
    unsigned char *input_buffer;        // Input Image buffer / Host
 
39
    unsigned char *cuda_input_buffer;   // Input Image buffer / Device
83
40
 
84
41
    cufftReal *cuda_base_buffer;        // Temporary buffer for FFT inputs, pre-zeroed
85
42
    cufftReal *cuda_data_buffer;        // Temporary buffer for FFT inputs, pre-zeroed
94
51
 
95
52
    float *cuda_lsum_temp;              // Temporary buffer for local sum comp, first two pre-zeroed
96
53
    
97
 
 
 
54
    
 
55
    float *res_x;                       // External points buffer
 
56
    float *res_y;                       // External points buffer
 
57
    
98
58
 
99
59
    int fft_initialized;                // Flag indicating if CUFFT plan is initialized
100
60
    cufftHandle cufft_plan;
111
71
 
112
72
    int ncp;                    // Number of control points
113
73
    int ncp_alloc_size;
 
74
    
 
75
    int width;                  // Images width
 
76
    int height;                 // Images height
114
77
 
115
78
    int corr_size;              // CORR_SIZE 
116
79
    int precision;              // PRECISION
134
97
 
135
98
typedef struct STProcessingState TProcessingState;
136
99
 
137
 
#ifndef EXTERN_C
138
 
# ifdef __cplusplus
139
 
   #define EXTERN_C extern "C"
140
 
# else
141
 
   #define EXTERN_C extern
142
 
# endif
143
 
#endif
144
100
 
145
 
#ifdef USE_UNDOCUMENTED
146
 
EXTERN_C mxArray *mxCreateSharedDataCopy(const mxArray *pr);
147
 
#endif /* USE_UNDOCUMENTED */
148
101
 
149
102
#endif /* NORMXCORR_HW_H */