-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathgrok_core_java.i.in
More file actions
77 lines (68 loc) · 2.27 KB
/
grok_core_java.i.in
File metadata and controls
77 lines (68 loc) · 2.27 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
70
71
72
73
74
75
76
77
%module grok_core_java
%{
#include "@GROK_CORE_INCLUDE_PATH@/grok.h"
%}
%include stdint.i
%include various.i
%include "@GROK_CORE_INCLUDE_PATH@/grok.h"
/* Indexed access to image components */
%extend _grk_image {
grk_image_comp* get_comp(int index) {
if (index < 0 || index >= self->numcomps)
return NULL;
return &self->comps[index];
}
}
%inline %{
/* Create an image where all components share the same dimensions and precision */
grk_image* grk_image_new_uniform(uint16_t numcmpts, uint32_t w, uint32_t h,
uint8_t dx, uint8_t dy, uint8_t prec,
bool sgnd, GRK_COLOR_SPACE clrspc) {
grk_image_comp* comps = (grk_image_comp*)calloc(numcmpts, sizeof(grk_image_comp));
if (!comps)
return NULL;
for (uint16_t i = 0; i < numcmpts; i++) {
comps[i].w = w;
comps[i].h = h;
comps[i].dx = dx;
comps[i].dy = dy;
comps[i].prec = prec;
comps[i].sgnd = sgnd;
}
grk_image* img = grk_image_new(numcmpts, comps, clrspc, true);
free(comps);
if (img) {
for (uint16_t i = 0; i < numcmpts; i++) {
if (img->comps[i].data) {
size_t pixels = (size_t)img->comps[i].stride * img->comps[i].h;
memset(img->comps[i].data, 0, pixels * sizeof(int32_t));
}
}
}
return img;
}
/* Set a layer rate on grk_cparameters (workaround for C array item assignment) */
void grk_cparameters_set_layer_rate(grk_cparameters* p, uint16_t layer, double rate) {
p->layer_rate[layer] = rate;
}
/* Set a layer distortion on grk_cparameters */
void grk_cparameters_set_layer_distortion(grk_cparameters* p, uint16_t layer, double distortion) {
p->layer_distortion[layer] = distortion;
}
%}
%extend _grk_progression_state {
uint16_t get_max_layers() {
uint16_t max_layer = 0;
for (int i = 0; i < self->num_resolutions; i++) {
if (self->layers_per_resolution[i] > max_layer) {
max_layer = self->layers_per_resolution[i];
}
}
return max_layer;
}
void set_max_layers(uint16_t value) {
for (int i = 0; i < self->num_resolutions; i++) {
self->layers_per_resolution[i] = value;
}
}
}