-
Notifications
You must be signed in to change notification settings - Fork 9
/
utils.h
133 lines (113 loc) · 1.93 KB
/
utils.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
============================================================================
Name : general_lincoln.h
Author : LincolnHard
Version :
Copyright : free and open
Description : Hello World in C, Ansi-style
============================================================================
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define IMG_WIDTH 640
#define IMG_HEIGHT 480
#define MEMORYPOOL_TOTAL_SIZE 0x300000 //3Mbytes
#define VECTOR_INIT_SIZE 512
typedef struct
{
float x;
float y;
}point_2f32_lincoln;
typedef struct
{
unsigned short width;
unsigned short height;
}imsize_u16_lincoln;
typedef struct
{
unsigned short x;
unsigned short y;
unsigned short w;
unsigned short h;
}rect_u16_lincoln;
typedef struct
{
void* beginning;
size_t elem_size;
size_t num_elems;
size_t num_alloc_elems;
}vector_lincoln;
void init_memory_pool_lincoln
(
void
);
void* malloc_lincoln
(
size_t len
);
void free_memory_pool_lincoln
(
void
);
void vector_init_lincoln
(
vector_lincoln* vec,
size_t elem_size,
size_t init_elem_num
);
void vector_push_lincoln
(
vector_lincoln* vec,
void* elem
);
void vector_pop_lincoln
(
vector_lincoln* vec,
void* elem
);
void vector_clear_lincoln
(
vector_lincoln* vec
);
void vector_qsort_lincoln
(
vector_lincoln* vec,
int (*compare_func)(const void*, const void*)
);
void read_pgm
(
char* filename,
unsigned char* src
);
void write_pgm
(
char* filename,
const unsigned char* src,
imsize_u16_lincoln src_size,
rect_u16_lincoln* roi
);
void draw_rectangle
(
unsigned char* src,
rect_u16_lincoln* rectptr
);
unsigned int int_sqrt
(
unsigned int value
);
unsigned short u16_round_lincoln
(
float fvalue
);
void resize_interpolation
(
const unsigned char* src,
const rect_u16_lincoln* srcroi,
const imsize_u16_lincoln dstsize,
unsigned char* dst
);
#endif /* UTILS_H_ */