27 "yarp.carrier.portmonitor.zfp",
37 shouldCompress = (options.
find(
"sender_side").
asBool());
39 decompressed =
nullptr;
60 decompressed =
nullptr;
79 yCError(ZFPMONITOR,
"Expected type ImageOf<PixelFloat> in sender side, but got wrong data type!");
86 yCError(ZFPMONITOR,
"Expected type Bottle in receiver side, but got wrong data type!");
103 compress((
float*)img->getRawImage(), compressed, sizeCompressed, img->width(),img->height(),1e-3);
105 yCError(ZFPMONITOR,
"Failed to compress, exiting...");
109 data.addInt32(img->width());
110 data.addInt32(img->height());
111 data.addInt32(sizeCompressed);
112 Value v(compressed, sizeCompressed);
114 th.setPortWriter(&data);
123 int sizeCompressed=compressedbt->
get(2).
asInt32();
125 decompress((
float*)compressedbt->
get(3).
asBlob(), decompressed, sizeCompressed, width, height,1e-3);
128 yCError(ZFPMONITOR,
"Failed to decompress, exiting...");
131 imageOut.resize(width,height);
132 memcpy(imageOut.getRawImage(),decompressed,width*height*4);
133 th.setPortWriter(&imageOut);
141 if(newSize>sizeToAllocate){
142 sizeToAllocate=newSize;
144 array=(
float*) malloc(sizeToAllocate);
150 if(newSize>sizeToAllocateB){
151 sizeToAllocateB=newSize;
153 array=(
void*) malloc(sizeToAllocateB);
167 type = zfp_type_float;
168 field = zfp_field_2d(array, type, nx, ny);
171 zfp = zfp_stream_open(
nullptr);
176 zfp_stream_set_accuracy(zfp, tolerance);
179 bufsize = zfp_stream_maximum_size(zfp, field);
184 stream = stream_open(
buffer, bufsize);
185 zfp_stream_set_bit_stream(zfp, stream);
186 zfp_stream_rewind(zfp);
190 zfpsize = zfp_compress(zfp, field);
192 yCError(ZFPMONITOR,
"compression failed");
196 resizeF(compressed,zfpsize);
197 memcpy(compressed,(
float*) stream_data(zfp->stream),zfpsize);
200 zfp_field_free(field);
201 zfp_stream_close(zfp);
202 stream_close(stream);
215 type = zfp_type_float;
216 resizeF(decompressed,nx*ny*
sizeof(
float));
217 field = zfp_field_2d(decompressed, type, nx, ny);
220 zfp = zfp_stream_open(
nullptr);
225 zfp_stream_set_accuracy(zfp, tolerance);
228 bufsize = zfp_stream_maximum_size(zfp, field);
230 memcpy(
buffer,array,zfpsize);
233 stream = stream_open(
buffer, zfpsize);
234 zfp_stream_set_bit_stream(zfp, stream);
235 zfp_stream_rewind(zfp);
238 if (!zfp_decompress(zfp, field)) {
239 yCError(ZFPMONITOR,
"decompression failed");
244 zfp_field_free(field);
245 zfp_stream_close(zfp);
246 stream_close(stream);