Applications/Libjpeg-turbo
From HPC
Application Details
- Description: libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, AVX2, NEON, AltiVec) to accelerate baseline JPEG compression .
- Version: 1.5.1 (compiled with gcc)
- Module: gcc/1.5.1
- Licence: GNU
Usage Examples
Module
[username@login01 ~]$ module add libjpeg-turbo/gcc/1.5.1
Compilation
Libjpeg-turbo is a library for use either with a compiled binary that requires it, or it could be required at compilation time also.
A typical code snippet (C++) requiring is shown below:
#include <turbojpeg.h>
const int JPEG_QUALITY = 85;
const int COLOR_COMPONENTS = 3;
int _width = 640;
int _height = 720;
long unsigned int _jpegSize = 0;
unsigned char* _compressedImage = NULL;
unsigned char buffer[_width*_height*COLOR_COMPONENTS];
tjhandle _jpegCompressor = tjInitCompress();
tjCompress2(_jpegCompressor, buffer, _width, 0, _height, TJPF_RGB,
&_compressedImage, &_jpegSize, TJSAMP_444, JPEG_QUALITY,
TJFLAG_FASTDCT);
tjDestroy(_jpegCompressor);
//to free the memory allocated by TurboJPEG
tjFree(&_compressedImage);
Compilation is carried out below, in this example the gcc compiler is used. However, the applies similarly to the Intel compiler too.
gcc -o tjIMAGE tjIMAGE.cpp -lm -ljpeg