The console application gpujpeg uses libgpujpeg library to demonstrate it's functions. To build console application check Requirements and go to gpujpeg directory (where README and LICENSE files are placed) and run 'make' command. It builds libgpugjpeg library in subdirectory ./libgpujpeg/ and it creates executable file ./gpujpeg and run script ./gpujpeg.sh, which runs executable file linked to runtime library libgpujpeg.so (which is placed in ./libgpujpeg/ subdirectory).
To be able to build and run libgpujpeg library and gpujpeg console application you need:
The libgpujpeg library uses NVIDIA Performance Primitives library, but it is included in CUDA toolkit. There were some build error in npp headers when using some specific versions of GCC and NPP library. If you encounter these kind of problem, try to use the newest version of CUDA toolkit or older version of GCC.
To encode image from raw RGB image file to JPEG image file use following command:
./gpujpeg.sh --encode --size=WIDTHxHEIGHT --quality=QUALITY \
INPUT_IMAGE.rgb OUTPUT_IMAGE.jpg
You must specify input image size by --size=WIDTHxHEIGHT parameter. Optionally you can specify desired output quality by parameter --quality=QUALITY which accepts values 0-100. Console application accepts a few more parameters and you can list them by folling command:
./gpujpeg.sh --help
To decode image from JPEG image file to raw RGB image file use following command:
./gpujpeg.sh --decode OUTPUT_IMAGE.jpg INPUT_IMAGE.rgb
You can also encode and decode image to test the console application:
./gpujpeg.sh --encode --decode --size=WIDTHxHEIGHT --quality=QUALITY \
INPUT_IMAGE.rgb OUTPUT_IMAGE.jpg
Decoder will create new decoded file OUTPUT_IMAGE.jpg.decoded.rgb and do not overwrite your INPUT_IMAGE.rgb file. Console application is able to load raw RGB image file data from .rgb files and raw YUV and YUV422 data from .yuv files. For YUV422 you must specify *.yuv file and use '--sampling-factor=4:2:2' parameter.
All supported parameters for console application are following:
Restart interval is important for parallel huffman encoding and decoding. When '--restart=N' is used (default is 8), the coder can process each N MCUs independently, and so he can code each N MCUs in parallel. When '--restart=0' is specified, restart interval is disabled and the coder must use CPU version of huffman coder (because on GPU would run only one thread, which is very slow).
The console application can encode/decode multiple images by following command:
./gpujpeg.sh ARGUMENTS INPUT_IMAGE_1.rgb OUTPUT_IMAGE_1.jpg \
INPUT_IMAGE_2.rgb OUTPUT_IMAGE_2.jpg ...