jd_decomp

The jd_decomp function decompress the JPEG image and output it as pixel data.

JRESULT jd_decomp (
  JDEC* jdec,             /* Pointer to valid decompression object */
  int(*outfunc)(JDEC*,void*,JRECT*), /* Pointer to output function */
  uint8_t scale           /* Scaling factor */
);

Parameters

jdec
Specifies the valid decompressor object.
outfunc
Specifies the user defined data output function. The jd_decomp function calls this function to output the decompressed JPEG image in pre-defined pixel format.
scale
Specifies scaling factor N for output. The output image is descaled to 1/2N (N = 0 to 3). When scaling feature is disabled (JD_USE_SCALE == 0), it must be 0.

Return Values

JDR_OK
Function succeeded.
JDR_INTR
The decompression process was interrupted by output function.
JDR_INP
An error occured in input function due to hard error or wrong stream termination.
JDR_PAR
Parameter error. Given scale factor is invalid.
JDR_FMT1
Data format error. The input JPEG data can be collapted.

Description

The jd_decomp function is the second stage of a JPEG decompression session. It decompresses the input JPEG stream and outputs it via user defined output function. After this function, the decompressor object is no longer valid.

The scaling factor can be specified on decompresson. It descales the size of the output image by 1/2, 1/4 or 1/8. For example, when decompress a JPEG image of 1024x768 in 1/4 scaling, the decmopressed image will be output in 256x192. The scaling ratio of 1/2 and 1/4 will slightly decrease the decompression speed compared to 1/1 due to averaging process. However scaling ratio of 1/8 will 2-3 times faster than 1/1, because IDCT and averaging process for each block can be skipped. This characteristic is sutable to create thumbnails.

Return