24{ itsCompressor = tjInitCompress(); }
28{ tjDestroy(itsCompressor); }
32{
return itsCompressor; }
37 size_t const sz = width * height;
38 unsigned char * uptr = dst + sz;
39 unsigned char * vptr = uptr + sz / 4;
40 size_t const sz2 = sz / 2;
42 for (
size_t i = 0; i < sz2; ++i)
55 unsigned long jpegsize = width * height * 2;
59 tjCompress2(compressor,
const_cast<unsigned char *
>(src), width, 0, height, TJPF_BGR,
60 &dst, &jpegsize, TJSAMP_422, quality, TJFLAG_FASTDCT);
69 unsigned long jpegsize = width * height * 2;
73 tjCompress2(compressor,
const_cast<unsigned char *
>(src), width, 0, height, TJPF_RGB,
74 &dst, &jpegsize, TJSAMP_422, quality, TJFLAG_FASTDCT);
83 unsigned long jpegsize = width * height * 2;
87 tjCompress2(compressor,
const_cast<unsigned char *
>(src), width, 0, height, TJPF_RGBA,
88 &dst, &jpegsize, TJSAMP_422, quality, TJFLAG_FASTDCT);
97 unsigned long jpegsize = width * height * 2;
101 tjCompress2(compressor,
const_cast<unsigned char *
>(src), width, 0, height, TJPF_GRAY,
102 &dst, &jpegsize, TJSAMP_422, quality, TJFLAG_FASTDCT);
void * compressor()
Access the compressor handle.
virtual ~JpegCompressor()
Destructor, frees the turbojpeg object.
JpegCompressor()
Constructor, create the turbojpeg object.
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
T * pixelsw()
Shortcut access to pixels, read-write.
std::shared_ptr< VideoBuf > buf
The pixel data buffer.
static JpegCompressor & instance()
Get the global, unique instance of the class T.
unsigned long compressGRAYtoJpeg(unsigned char const *src, int width, int height, unsigned char *dst, int quality=75)
Compress raw pixel buffer to jpeg.
unsigned long compressBGRtoJpeg(unsigned char const *src, int width, int height, unsigned char *dst, int quality=75)
Compress raw pixel buffer to jpeg.
unsigned long compressRGBAtoJpeg(unsigned char const *src, int width, int height, unsigned char *dst, int quality=75)
Compress raw pixel buffer to jpeg.
void convertYUYVtoYUV422(unsigned char const *src, int width, int height, unsigned char *dst)
Helper to convert from packed YUYV to planar YUV422.
unsigned long compressRGBtoJpeg(unsigned char const *src, int width, int height, unsigned char *dst, int quality=75)
Compress raw pixel buffer to jpeg.