// // Created by YY on 2021/12/2. // #include #include #include #include "jpeg.h" #include "jpeglib.h" #include "turbojpeg.h" static tjhandle handle = NULL; void init_JPEG_turbo(void) { handle = tjInitDecompress(); } void uninit_JPEG_turbo(void) { if (handle) { tjDestroy(handle); handle = NULL; } } void read_JPEG_turbo(const uint8_t *jpg, int length, uint8_t *rgba) { int width, height, subsample, colorspace; tjDecompressHeader3(handle, jpg, length, &width, &height, &subsample, &colorspace); tjDecompress2(handle, jpg, length, rgba, width, 0, height, TJPF_RGBA, TJFLAG_FASTDCT| TJFLAG_FASTUPSAMPLE); }