Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6628 Discussions

How I to use Intel IPP JPEG Viewer Sample for Windows* ?

New Contributor I
The website said:

Which Intel IPP JPEG encoder/decoder is faster than the IJL?
The Intel IPP JPEG codec from the JPEGView sample is implemented for maximum performance and is faster than IJL v1.51 and the IJL-IPP sample.

So I have download the JPEGView sample.

Badly, The JPEGView sample is without sample example. and there is only a brief d ocumentation within it :

For encode :


This sample demonstrates how to use the Intel IPP functions to create a JPEG encoder/decoder. The sample contains JPEG encoder/decoder which resides in the jpegcodec folder and MFC application that allows opening, viewing and creating JPEG files. The JPEG encoder/decoder takes advantage of the Hyper-Threading Technology (HT Technology) found in the latest Intel Pentium 4 processors. The JPEG encoder/decoder is based on the international standard ISO/IEC 10918-1. The IPP JPEG codec provides the following public methods:

encoder (see jpegcodec/jpegenc.h file for details)

  • SetSource(Ipp8u* pSrc, int srcStep, IppiSize srcSize, int srcChannels, JCOLOR srcColor, JSS srcSampling, int srcPrecision)
  • SetSource(Ipp16s* pSrc, int srcStep, IppiSize srcSize, int srcChannels, JCOLOR srcColor, JSS srcSampling, int srcPrecision)
    Use these methods to set up source image to compress with IPP JPEG codec
  • SetDestination(CBaseStreamOutput* pStreamOut)
    Use this method to set up where to output resulting JPEG bitstream. You can use memory buffer or byte stream, see CStdFileOutput or CMemBuffOutput classes for example
  • SetParams(JMODE mode, JCOLOR color, JSS sampling, int restart_interval, int huff_opt, int quality)
  • SetParams(JMODE mode, JCOLOR color, JSS sampling, int restart_interval, int huff_opt, int point_transform, int predictor)
    Use these methods to set up encoder control parameters. Use the first method for JPEG_BASELINE and JPEG_PROGRESSIVE modes, use the second method for JPEG_LOSSLESS mode. See ./jpegcodec/jpegbase.h file for definitions of JMODE, JCOLOR, JSS
  • InitHuffmanTable(int tbl_id, HTBL_CLASS tbl_class, Ipp8u bits[16], Ipp8u vals[256])
    This method allows you to replace default huffman table. Use it carefully, huffman table must match encoded data. Do not use this methods if you are not familiar with JPEG details.
  • AttachHuffmanTable(int tbl_id, int comp_no)
    This method allows you to change default connection of huffman tables and JPEG color components. The IPP JPEG codec by default connects huffman table with id = 0 to the first component in scan and uses table with id = 1 for other components.
  • InitQuantTable(int tbl_id, Ipp8u qnt[64], int quality)
  • InitQuantTable(int tbl_id, Ipp16u qnt[64], int quality)
    These methods allow you to replace default quantization tables, for both 8-bit and 16-bit precision. Note, that you need to set quality parameter to zero to avoid re-scaling table's values.
  • AttachQuantTable(int tbl_id, int comp_no)
    This method allow you to change default connection of quantization tables with JPEG color components.
  • WriteHeader()
    Use this method to generate JPEG header, which include SOI, APP1, DQT, SOF, DHT segments. Separate calls of WriteHeader and WriteData methods allow you to write abbreviated JPEG files. Note, that DHT segment is not applied in WriteHeader for JPEG_PROGRESSIVE mode.
  • WriteData()
    Use this method to actually encode the data
  • NumOfBytes()
    This method provides the size of generated JPEG bitstream after call of WriteData. It is useful when encoding to memory buffer is used.


The parameter is hard to unstand what it is, and the JPEGView is heavy on OOP (TRUE C++ code) with inherit , they relation is not easy to understand .

so, where I could get a simple example?

I post my example code :

/*load bmp file by OpenCV, trans data in the pSrcBuf, nBitcount = 3 for RGB format */

#define PIXELSIZE3 3
#define TENMB 1073741824 /*for maxima buffer*/

JPEGVIEWERENCODE_EXPORTS_API int JpegViewer_Encode(void *pDstBuf, unsigned int &JpegSize, int width, int height, void *pSrcBuf, int nBitcount, int quality)

CJPEGEncoder encoder;

unsigned char *src;
src =(unsigned char*) pSrcBuf;
//dst = (unsigned char*)pDstBuf;
IppiSize srcSize;
srcSize.width = width;
srcSize.height = height;
int srcStep = 1;
int srcChannels = PIXELSIZE3;
JCOLOR srcColor = JC_BGR;
JSS srcSampling = JS_444;
int srcPrecision = 8;

/*my data is by pixel array format: R[0]G[0]B[0] R[1]G[1]B[1] R[2]G[2]B[2].......I do not know
what is srcSampling and srcStep meaning here.*/

encoder.SetSource( src, srcStep , srcSize, srcChannels, srcColor, srcSampling, srcPrecision);

CMemBuffOutput dst;
dst.Open((unsigned char*) pDstBuf, TENMB);

/*I do not know what the parameters mean:
restart_interval, int huff_opt in SetParams(JMODE mode, JCOLOR color, JSS sampling, int restart_interval, int huff_opt, int quality)

encoder.SetParams(JPEG_BASELINE, srcColor, srcSampling, 512*512, 1, quality) ;
JpegSize = encoder.NumOfBytes();

return 1;

The output is just pink when I input lena 512*512~....

May someone could help ? thank you lots...

0 Kudos
2 Replies
New Contributor I
Oh, I have solve the problem, it is I have convert no-exist format (JC_BGR to JC_RGB)

and I do not turn on the warrning message in jegbase or proprecessor define flag ENABLE_ERROR_LOGGING.

Hi Chen,

JPEGView sample demonstrate previous generation of JPEG codec. Since that time we have developed Unified Image Codec framework, which is C++ base interface for image codecs and inherited implementation of JPEG, JPEG2000, PNG codecs. It take the best from JPEGView design and add unification, I would recommend you to take a look at it. It is image codec interface we committed to extend in future. For example, in IPP 7.0 beta (which is coming soon) we plan to add new JPEG-XR codec support and base support for TIFF format (uncompressed at this time).

You may find UIC sample in image-codecs\uic folder of your IPP sample package. There are also two sample applications which show how to use UIC codecs in application.