-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocessor.cpp
180 lines (152 loc) · 5.15 KB
/
processor.cpp
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include <OpenColorIO/OpenColorIO.h>
#include "ocio.h"
#include "ocio_abi.h"
#include "storage.h"
namespace OCIO = OCIO_NAMESPACE;
namespace ocigo {
IndexMap<OCIO::ProcessorRcPtr> g_Processor_map;
IndexMap<OCIO::ProcessorMetadataRcPtr> g_ProcessorMetadata_map;
}
extern "C" {
void deleteProcessor(ProcessorId p) {
if (p != NULL) {
if (p->handle) {
ocigo::g_Processor_map.remove(p->handle);
p->handle = 0;
}
freeHandleContext(p);
}
}
ProcessorId Processor_Create() {
OCIO::ProcessorRcPtr ptr;
ProcessorId p = NEW_HANDLE_CONTEXT();
BEGIN_CATCH_CTX_ERR(p)
p->handle = ocigo::g_Processor_map.add(OCIO::Processor::Create());
END_CATCH_CTX_ERR(p)
return p;
}
bool Processor_isNoOp(ProcessorId p) {
bool ret = false;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Processor_map.get(p->handle).get()->isNoOp();
END_CATCH_CTX_ERR(p)
return ret;
}
bool Processor_hasChannelCrosstalk(ProcessorId p) {
bool ret = false;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Processor_map.get(p->handle).get()->hasChannelCrosstalk();
END_CATCH_CTX_ERR(p)
return ret;
}
// Processor CPU
void Processor_apply(ProcessorId p, ImageDesc *i) {
OCIO::ImageDesc *img = static_cast<OCIO::ImageDesc*>(i);
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Processor_map.get(p->handle).get()->apply(*img);
END_CATCH_CTX_ERR(p)
}
const char* Processor_getCpuCacheID(ProcessorId p) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Processor_map.get(p->handle).get()->getCpuCacheID();
END_CATCH_CTX_ERR(p)
return ret;
}
// ProcessorMetadata
void deleteProcessorMetadata(ProcessorMetadataId p) {
ocigo::g_ProcessorMetadata_map.remove(p);
}
ProcessorMetadataId Processor_getMetadata(ProcessorId p) {
OCIO::ConstProcessorMetadataRcPtr ptr;
BEGIN_CATCH_CTX_ERR(p)
ptr = ocigo::g_Processor_map.get(p->handle).get()->getMetadata();
END_CATCH_CTX_ERR(p)
return ocigo::g_ProcessorMetadata_map.add(
OCIO_CONST_POINTER_CAST<OCIO::ProcessorMetadata>(ptr));
}
ProcessorMetadataId ProcessorMetadata_Create() {
OCIO::ProcessorMetadataRcPtr ptr;
BEGIN_CATCH_ERR
ptr = OCIO::ProcessorMetadata::Create();
END_CATCH_ERR
return ocigo::g_ProcessorMetadata_map.add(ptr);
}
int ProcessorMetadata_getNumFiles(ProcessorMetadataId p) {
int ret = 0;
BEGIN_CATCH_ERR
ret = ocigo::g_ProcessorMetadata_map.get(p).get()->getNumFiles();
END_CATCH_ERR
return ret;
}
const char* ProcessorMetadata_getFile(ProcessorMetadataId p, int index) {
const char* ret = NULL;
BEGIN_CATCH_ERR
ret = ocigo::g_ProcessorMetadata_map.get(p).get()->getFile(index);
END_CATCH_ERR
return ret;
}
int ProcessorMetadata_getNumLooks(ProcessorMetadataId p) {
BEGIN_CATCH_ERR
return ocigo::g_ProcessorMetadata_map.get(p).get()->getNumLooks();
END_CATCH_ERR
}
const char* ProcessorMetadata_getLook(ProcessorMetadataId p, int index) {
const char* ret = NULL;
BEGIN_CATCH_ERR
ret = ocigo::g_ProcessorMetadata_map.get(p).get()->getLook(index);
END_CATCH_ERR
return ret;
}
void ProcessorMetadata_addFile(ProcessorMetadataId p, const char* fname) {
BEGIN_CATCH_ERR
ocigo::g_ProcessorMetadata_map.get(p).get()->addFile(fname);
END_CATCH_ERR
}
void ProcessorMetadata_addLook(ProcessorMetadataId p, const char* look) {
BEGIN_CATCH_ERR
ocigo::g_ProcessorMetadata_map.get(p).get()->addLook(look);
END_CATCH_ERR
}
// ImageDesc
void deletePackedImageDesc(PackedImageDesc* p) {
if (p != NULL) {
delete (OCIO::PackedImageDesc*)p;
}
}
PackedImageDesc* PackedImageDesc_Create(float* data, long width, long height, long numChannels) {
PackedImageDesc* ret = NULL;
BEGIN_CATCH_ERR
ret = (PackedImageDesc*) new OCIO::PackedImageDesc(data, width, height, numChannels);
END_CATCH_ERR
return ret;
}
float* PackedImageDesc_getData(PackedImageDesc *p) {
float* ret = NULL;
BEGIN_CATCH_ERR
ret = static_cast<OCIO::PackedImageDesc*>(p)->getData();
END_CATCH_ERR
return ret;
}
long PackedImageDesc_getWidth(PackedImageDesc *p) {
long ret = 0;
BEGIN_CATCH_ERR
ret = static_cast<OCIO::PackedImageDesc*>(p)->getWidth();
END_CATCH_ERR
return ret;
}
long PackedImageDesc_getHeight(PackedImageDesc *p) {
long ret = 0;
BEGIN_CATCH_ERR
ret = static_cast<OCIO::PackedImageDesc*>(p)->getHeight();
END_CATCH_ERR
return ret;
}
long PackedImageDesc_getNumChannels(PackedImageDesc *p) {
long ret = 0;
BEGIN_CATCH_ERR
ret = static_cast<OCIO::PackedImageDesc*>(p)->getNumChannels();
END_CATCH_ERR
return ret;
}
}