-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
69 lines (59 loc) · 1.51 KB
/
utils.h
File metadata and controls
69 lines (59 loc) · 1.51 KB
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
#include <mpi.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
/*
* Error checking macro
* Eg:
* int fd = open(file_name, O_RDONLY);
* DIE(fd == -1, "open failed");
*/
#define DIE(assertion, call_description) \
do { \
if (assertion) { \
fprintf(stderr, "(%s, %d): ", \
__FILE__, __LINE__); \
perror(call_description); \
exit(EXIT_FAILURE); \
} \
} while(0)
#define COMMENT_LEN 47
#define MASTER_PROC 0
#define MIN(x, y) ((x < y) ? x : y)
#define MAX(x, y) ((x < y) ? y : x)
#define CLAMP(x, maxvalue) ((x > maxvalue) ? maxvalue : ((x < 0.f) ? 0 : (unsigned char) x))
/*
* P5 = PGM = black & white
* P6 = PNM = color
*/
#pragma pack(push, 1)
typedef struct _pixel {
unsigned char r;
unsigned char g;
unsigned char b;
}pixel_t;
typedef struct _img {
unsigned char P;
int width;
int height;
char comment[COMMENT_LEN];
unsigned char maxval;
unsigned char* data;
}img_t;
#pragma pack(pop)
img_t* parse_img(char* filename);
void flush_img(char* filename, img_t* image);
float* get_filter(char* filter);
unsigned char* apply_filter_chunk(
unsigned char P, unsigned char maxvalue,
int rank, int nProcesses, char* filter_name,
int line_width, int buff_len,
unsigned char* img_data,
unsigned char* upper_line,
unsigned char* bottom_line);
void destroy_img(img_t* image);