24 #include <fvutils/net/fuse_lut_content.h>
25 #include <fvutils/ipc/shm_lut.h>
27 #include <core/exceptions/system.h>
28 #include <core/exceptions/software.h>
31 #include <netinet/in.h>
34 namespace firevision {
52 FuseLutContent::FuseLutContent(uint32_t type,
53 void *payload,
size_t payload_size)
55 if ( (type != FUSE_MT_LUT) && (type != FUSE_MT_SET_LUT) ) {
57 type, FUSE_MT_LUT, FUSE_MT_SET_LUT);
60 _payload_size = payload_size;
67 __lut_id = (
char *)malloc(LUT_ID_MAX_LENGTH + 1);
68 __lut_id[LUT_ID_MAX_LENGTH] = 0;
69 strncpy(__lut_id, __header->lut_id, LUT_ID_MAX_LENGTH);
71 __buffer_size = ntohl(__header->width) * ntohl(__header->height) *
72 ntohl(__header->depth) * ntohl(__header->bytes_per_cell);
84 _payload = malloc(_payload_size);
85 if ( _payload == NULL ) {
92 strncpy(__header->lut_id, b->
lut_id(), LUT_ID_MAX_LENGTH);
93 __header->width = htonl(b->
width());
94 __header->height = htonl(b->
height());
95 __header->depth = htonl(b->
depth());
97 __lut_id = strdup(b->
lut_id());
100 memcpy(__buffer, b->
buffer(), __buffer_size);
114 FuseLutContent::FuseLutContent(
const char *lut_id,
void *buffer,
115 unsigned int width,
unsigned int height,
116 unsigned int depth,
unsigned int bpc)
118 __buffer_size = width * height * depth * bpc;
121 _payload = malloc(_payload_size);
122 if ( _payload == NULL ) {
129 strncpy(__header->lut_id, lut_id, LUT_ID_MAX_LENGTH);
130 __header->width = htonl(width);
131 __header->height = htonl(height);
132 __header->depth = htonl(depth);
133 __header->bytes_per_cell = htonl(bpc);
134 __lut_id = strdup(lut_id);
136 memcpy(__buffer, buffer, __buffer_size);
140 FuseLutContent::~FuseLutContent()
150 FuseLutContent::lut_id()
const
159 FuseLutContent::buffer()
const
169 FuseLutContent::buffer_size()
const
171 return __buffer_size;
179 FuseLutContent::width()
const
181 return ntohl(__header->width);
189 FuseLutContent::height()
const
191 return ntohl(__header->height);
198 FuseLutContent::depth()
const
200 return ntohl(__header->depth);
208 FuseLutContent::bytes_per_cell()
const
210 return ntohl(__header->bytes_per_cell);
215 FuseLutContent::serialize()