19 int nibble = t_value & 0x7;
46 nibble =
m_word & 0xf0000000;
47 value |= (nibble << 1) >>
bits;
51 }
while(nibble & 0x80000000);
57 short* buffer2 = (
short*)t_buffer;
58 int* pHead =
m_pBuffer = (
int*)t_compressedBuf + 1;
60 short*
end = buffer2 + t_size /
m_bpp;
64 int zeros = 0, nonzeros = 0;
65 for(; (buffer2 !=
end) && !*buffer2; buffer2++, zeros++)
68 for(
short*
p = buffer2; (
p !=
end) && *
p++; nonzeros++)
71 for(
int i = 0;
i < nonzeros;
i++)
73 short current = *buffer2++;
74 int delta = current - previous;
75 int positive = (delta << 1) ^ (delta >> 31);
83 int compressWithHeaderSize = compressedSize +
sizeof(
compressedSize);
84 if(compressWithHeaderSize > t_size)
86 ERR <<
"Compression overflow, destination buffer is smaller than the compressed size";
89 memcpy(t_compressedBuf, &compressedSize,
sizeof(compressedSize));
94 memcpy(t_compressedBuf, &compressedSize,
sizeof(compressedSize));
95 return compressWithHeaderSize;
100 short* currentPtr = (
short*)t_uncompressedBuf;
103 short current, previous = 0;
105 int numPixelsToDecode = t_size / 2;
106 while(numPixelsToDecode)
109 numPixelsToDecode -= zeros;
110 for(; zeros; zeros--)
113 numPixelsToDecode -= nonzeros;
114 for(; nonzeros; nonzeros--)
117 int delta = (positive >> 1) ^ -(positive & 1);
118 current = previous + delta;
119 *currentPtr++ = current;
123 int uncompressedSize = int((
char*)currentPtr - (
char*)t_uncompressedBuf);
126 INF <<
"frame " <<
m_decompFrameCounter <<
"\tdepth\tcompression\tlz4\t" << compressedSize <<
"\t/\t" << uncompressedSize;
128 return uncompressedSize;
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
int decompressBuffer(unsigned char *t_buffer, int t_size, unsigned char *t_uncompressedBuf)
rs2_format
A stream's format identifies how binary data is encoded within a frame.
LZ4LIB_API char int compressedSize
RvlCompression(int t_width, int t_height, rs2_format t_format, int t_bpp)
int compressBuffer(unsigned char *t_buffer, int t_size, unsigned char *t_compressedBuf)