19 jpeg_create_decompress(&
m_dinfo);
23 m_cinfo.in_color_space = JCS_YCbCr;
28 m_cinfo.in_color_space = JCS_GRAYSCALE;
33 m_cinfo.in_color_space = JCS_RGB;
37 ERR <<
"unsupported format " << t_format <<
" for JPEG compression";
47 jpeg_destroy_decompress(&
m_dinfo);
48 jpeg_destroy_compress(&
m_cinfo);
53 for(
unsigned i = 0;
i <
m_cinfo.image_width;
i += 2)
68 for(
unsigned i = 0;
i <
m_cinfo.image_width;
i += 2)
83 for(
unsigned i = 0;
i <
m_dinfo.output_width;
i += 2)
95 for(
unsigned i = 0;
i <
m_dinfo.output_width;
i += 2)
131 unsigned char*
data =
nullptr;
132 jpeg_mem_dest(&
m_cinfo, &data, &compressedSize);
157 ERR <<
"unsupported format " <<
m_format <<
" for JPEG compression";
162 jpeg_finish_compress(&
m_cinfo);
163 int compressWithHeaderSize = compressedSize +
sizeof(int);
164 if(compressWithHeaderSize > t_size)
166 ERR <<
"compression overflow, destination buffer is smaller than the compressed size";
169 memcpy(t_compressedBuf, &compressedSize,
sizeof(
int));
170 memcpy(t_compressedBuf +
sizeof(
int), data, compressedSize);
176 return compressWithHeaderSize;
181 unsigned char* ptr = t_uncompressedBuf;
182 unsigned char*
data = t_buffer;
183 unsigned int jpegHeader{},
res{};
184 jpeg_mem_src(&
m_dinfo, data, t_compressedSize);
185 if(t_buffer !=
nullptr)
187 memcpy(&jpegHeader, t_buffer,
sizeof(
unsigned int));
189 if(jpegHeader != 0xE0FFD8FF)
191 ERR <<
"Not a JPEG frame, skipping";
197 ERR <<
"Cannot read JPEG header";
202 m_dinfo.out_color_space = JCS_RGB;
206 m_dinfo.out_color_space = JCS_YCbCr;
210 m_dinfo.out_color_space = JCS_GRAYSCALE;
214 ERR <<
"Unsupported format " <<
m_format <<
" for the JPEG compression";
220 ERR <<
"jpeg_start_decompress failed";
229 ERR <<
"jpeg_read_scanlines failed at " << numLines;
253 ERR <<
"jpeg_finish_decompress failed";
259 INF <<
"frame " <<
m_decompFrameCounter <<
"\tcolor\tdecompression\tJPEG\t" << t_compressedSize <<
"\t/\t" << uncompressedSize;
261 return uncompressedSize;
struct jpeg_compress_struct m_cinfo
void convertYUVtoUYVY(unsigned char **t_uncompressBuff)
void convertUYVYtoYUV(unsigned char **t_buffer)
int compressBuffer(unsigned char *t_buffer, int t_size, unsigned char *t_compressedBuf)
JSAMPROW m_row_pointer[1]
JpegCompression(int t_width, int t_height, rs2_format t_format, int t_bpp)
void convertRGBtoBGR(unsigned char **t_uncompressBuff)
int decompressBuffer(unsigned char *t_buffer, int t_size, unsigned char *t_uncompressedBuf)
struct jpeg_error_mgr m_jerr
unsigned __int64 uint64_t
rs2_format
A stream's format identifies how binary data is encoded within a frame.
void convertYUYVtoYUV(unsigned char **t_buffer)
LZ4LIB_API char int compressedSize
unsigned char * m_rowBuffer
void convertBGRtoRGB(unsigned char **t_buffer)
void convertYUVtoYUYV(unsigned char **t_uncompressBuff)
struct jpeg_decompress_struct m_dinfo