Developer World
Spresense SDK Library v3.3.0-375c679
JPEG Decoder API

JPEG Decoder is based on libjpeg library. More...

Classes

struct  JQUANT_TBL
 
struct  JHUFF_TBL
 
struct  jpeg_component_info
 
struct  jpeg_scan_info
 
struct  jpeg_marker_struct
 
struct  jpeg_common_struct
 
struct  jpeg_compress_struct
 
struct  jpeg_decompress_struct
 
struct  jpeg_error_mgr
 
struct  jpeg_progress_mgr
 
struct  jpeg_destination_mgr
 
struct  jpeg_source_mgr
 
struct  jpeg_memory_mgr
 

Macros

#define JPEG_LIB_VERSION   90 /* Compatibility version 9.0 */
 
#define JPEG_LIB_VERSION_MAJOR   9
 
#define JPEG_LIB_VERSION_MINOR   5
 
#define DCTSIZE   8 /* The basic DCT block is 8x8 coefficients */
 
#define DCTSIZE2   64 /* DCTSIZE squared; # of elements in a block */
 
#define NUM_QUANT_TBLS   4 /* Quantization tables are numbered 0..3 */
 
#define NUM_HUFF_TBLS   4 /* Huffman tables are numbered 0..3 */
 
#define NUM_ARITH_TBLS   16 /* Arith-coding tables are numbered 0..15 */
 
#define MAX_COMPS_IN_SCAN   4 /* JPEG limit on # of components in one scan */
 
#define MAX_SAMP_FACTOR   4 /* JPEG limit on sampling factors */
 
#define C_MAX_BLOCKS_IN_MCU   10 /* compressor's limit on blocks per MCU */
 
#define D_MAX_BLOCKS_IN_MCU   10 /* decompressor's limit on blocks per MCU */
 
#define JDCT_DEFAULT   JDCT_ISLOW
 
#define JDCT_FASTEST   JDCT_IFAST
 
#define jpeg_common_fields
 
#define JPOOL_PERMANENT   0 /* lasts until master record is destroyed */
 
#define JPOOL_IMAGE   1 /* lasts until done with image/datastream */
 
#define JPOOL_NUMPOOLS   2
 
#define JPP(arglist)   arglist
 
#define jpeg_create_compress(cinfo)
 
#define jpeg_create_decompress(cinfo)
 
#define JPEG_SUSPENDED   0
 
#define JPEG_HEADER_OK   1
 
#define JPEG_HEADER_TABLES_ONLY   2
 
#define JPEG_REACHED_SOS   1 /* Reached start of new scan */
 
#define JPEG_REACHED_EOI   2 /* Reached end of image */
 
#define JPEG_ROW_COMPLETED   3 /* Completed one iMCU row */
 
#define JPEG_SCAN_COMPLETED   4 /* Completed last iMCU row of a scan */
 
#define JPEG_RST0   0xD0 /* RST0 marker code */
 
#define JPEG_EOI   0xD9 /* EOI marker code */
 
#define JPEG_APP0   0xE0 /* APP0 marker code */
 
#define JPEG_COM   0xFE /* COM marker code */
 

Typedefs

typedef JSAMPLE FAR * JSAMPROW
 
typedef JSAMPROW * JSAMPARRAY
 
typedef JSAMPARRAY * JSAMPIMAGE
 
typedef JCOEF JBLOCK[DCTSIZE2]
 
typedef JBLOCK FAR * JBLOCKROW
 
typedef JBLOCKROW * JBLOCKARRAY
 
typedef JBLOCKARRAY * JBLOCKIMAGE
 
typedef JCOEF FAR * JCOEFPTR
 
typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr
 
typedef struct jpeg_common_structj_common_ptr
 
typedef struct jpeg_compress_structj_compress_ptr
 
typedef struct jpeg_decompress_structj_decompress_ptr
 
typedef struct jvirt_sarray_control * jvirt_sarray_ptr
 
typedef struct jvirt_barray_control * jvirt_barray_ptr
 

Enumerations

enum  J_COLOR_SPACE {
  JCS_UNKNOWN , JCS_GRAYSCALE , JCS_RGB , JCS_YCbCr ,
  JCS_CbYCrY , JCS_CMYK , JCS_YCCK , JCS_BG_RGB ,
  JCS_BG_YCC
}
 
enum  J_COLOR_TRANSFORM { JCT_NONE = 0 , JCT_SUBTRACT_GREEN = 1 }
 
enum  J_DCT_METHOD { JDCT_ISLOW , JDCT_IFAST , JDCT_FLOAT }
 
enum  J_DITHER_MODE { JDITHER_NONE , JDITHER_ORDERED , JDITHER_FS }
 

Functions

typedef JMETHOD (boolean, jpeg_marker_parser_method,(j_decompress_ptr cinfo))
 
struct jpeg_error_mgrjpeg_std_error (struct jpeg_error_mgr *err)
 
void jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
 
void jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
 
void jpeg_destroy_compress (j_compress_ptr cinfo)
 
void jpeg_destroy_decompress (j_decompress_ptr cinfo)
 
void jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
 
void jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile)
 
void jpeg_fd_src (j_decompress_ptr cinfo, int infd)
 
void jpeg_mem_dest (j_compress_ptr cinfo, unsigned char **outbuffer, size_t *outsize)
 
void jpeg_mem_src (j_decompress_ptr cinfo, const unsigned char *inbuffer, size_t insize)
 
void jpeg_set_defaults (j_compress_ptr cinfo)
 
void jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
 
void jpeg_default_colorspace (j_compress_ptr cinfo)
 
void jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
 
void jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, boolean force_baseline)
 
void jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
 
void jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, const unsigned int *basic_table, int scale_factor, boolean force_baseline)
 
int jpeg_quality_scaling (int quality)
 
void jpeg_simple_progression (j_compress_ptr cinfo)
 
void jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
 
JQUANT_TBLjpeg_alloc_quant_table (j_common_ptr cinfo)
 
JHUFF_TBLjpeg_alloc_huff_table (j_common_ptr cinfo)
 
JHUFF_TBLjpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno)
 
void jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables)
 
JDIMENSION jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
 
void jpeg_finish_compress (j_compress_ptr cinfo)
 
void jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
 
JDIMENSION jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, JDIMENSION num_lines)
 
void jpeg_write_marker (j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
 
void jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
 
void jpeg_write_m_byte (j_compress_ptr cinfo, int val)
 
void jpeg_write_tables (j_compress_ptr cinfo)
 
int jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
 
boolean jpeg_start_decompress (j_decompress_ptr cinfo)
 
JDIMENSION jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
 
JDIMENSION jpeg_read_mcus (j_decompress_ptr cinfo, JSAMPARRAY mcus, JDIMENSION max_lines, JDIMENSION *offset)
 
boolean jpeg_finish_decompress (j_decompress_ptr cinfo)
 
JDIMENSION jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, JDIMENSION max_lines)
 
boolean jpeg_has_multiple_scans (j_decompress_ptr cinfo)
 
boolean jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
 
boolean jpeg_finish_output (j_decompress_ptr cinfo)
 
boolean jpeg_input_complete (j_decompress_ptr cinfo)
 
void jpeg_new_colormap (j_decompress_ptr cinfo)
 
int jpeg_consume_input (j_decompress_ptr cinfo)
 
void jpeg_core_output_dimensions (j_decompress_ptr cinfo)
 
void jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
 
void jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, unsigned int length_limit)
 
void jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
 
jvirt_barray_ptr * jpeg_read_coefficients (j_decompress_ptr cinfo)
 
void jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
 
void jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
 
void jpeg_abort_compress (j_compress_ptr cinfo)
 
void jpeg_abort_decompress (j_decompress_ptr cinfo)
 
void jpeg_abort (j_common_ptr cinfo)
 
void jpeg_destroy (j_common_ptr cinfo)
 
boolean jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
 

Detailed Description

JPEG Decoder is based on libjpeg library.

Macro Definition Documentation

◆ jpeg_common_fields

#define jpeg_common_fields
Value:
struct jpeg_error_mgr * err; /* Error handler module */\
struct jpeg_memory_mgr * mem; /* Memory manager module */\
struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
void * client_data; /* Available for use by application */\
boolean is_decompressor; /* So common code can tell which is which */\
int global_state /* For checking call sequence validity */
Definition: jpeglib.h:731
Definition: jpeglib.h:844
Definition: jpeglib.h:789

◆ jpeg_create_compress

#define jpeg_create_compress (   cinfo)
Value:
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
(size_t) sizeof(struct jpeg_compress_struct))
Definition: jpeglib.h:312

◆ jpeg_create_decompress

#define jpeg_create_decompress (   cinfo)
Value:
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
(size_t) sizeof(struct jpeg_decompress_struct))
Definition: jpeglib.h:480

◆ JPEG_SUSPENDED

#define JPEG_SUSPENDED   0

Suspended due to lack of input data

◆ JPEG_HEADER_OK

#define JPEG_HEADER_OK   1

Found valid image datastream

◆ JPEG_HEADER_TABLES_ONLY

#define JPEG_HEADER_TABLES_ONLY   2

Found valid table-specs-only datastream

Function Documentation

◆ jpeg_destroy_decompress()

void jpeg_destroy_decompress ( j_decompress_ptr  cinfo)

Release JPEG decompression object.

Parameters
[in,out]cinfoPointer to JPEG decompression object
Returns
void

◆ jpeg_stdio_src()

void jpeg_stdio_src ( j_decompress_ptr  cinfo,
FILE *  infile 
)

Specify a file to JPEG data source by file pointer.

Note
Caller is responsible for opening the file before and closing after.
Parameters
[in,out]cinfoPointer toJPEG decompression object
[in]infileJPEG file pointer to be decoded
Returns
void

◆ jpeg_fd_src()

void jpeg_fd_src ( j_decompress_ptr  cinfo,
int  infd 
)

Specify a file to JPEG data source by file descriptor.

Note
Caller is responsible for opening the file before and closing after.
Parameters
[in,out]cinfoPointer to JPEG decompression object
[in]infdJPEG file descriptor to be decoded
Returns
void

◆ jpeg_mem_src()

void jpeg_mem_src ( j_decompress_ptr  cinfo,
const unsigned char *  inbuffer,
size_t  insize 
)

Specify a buffer to JPEG data source.

Note
The input buffer must contain the whole JPEG data.
Parameters
[in,out]cinfoPointer to JPEG decompression object
[in]inbufferPointer to buffer which include the whole JPEG data
[in]insizeSize of inbuffer
Returns
void

◆ jpeg_read_header()

int jpeg_read_header ( j_decompress_ptr  cinfo,
boolean  require_image 
)

Read JPEG header.

Note
Application need to complete one of jpeg_stdio_src, jpeg_fd_src or jpeg_mem_src in order to complete this API and proceed decode.
Parameters
[in,out]cinfoPointer to JPEG decompression object
[in]require_imageTrue means that decoder handle error and do not return in no-image case.
Returns
return value meaning
JPEG_SUSPENDED Suspended due to lack of input data.
This value can be returned if application used jpeg_mem_src for JPEG data source input.
JPEG_HEADER_OK Found valid image datastream
JPEG_HEADER_TABLES_ONLY Found valid table-specs-only datastream.
In require_image = true case, this value cannot be returned.

◆ jpeg_start_decompress()

boolean jpeg_start_decompress ( j_decompress_ptr  cinfo)

Start decompression.

Note
Application need to complete jpeg_read_header in order to complete this API and proceed decode.
Parameters
[in,out]cinfoPointer to JPEG decompression object
Returns
return value meaning
FALSE Suspended due to lack of input data.
This value can be returned if application used jpeg_mem_src for JPEG data source input.
TRUE Success

◆ jpeg_read_scanlines()

JDIMENSION jpeg_read_scanlines ( j_decompress_ptr  cinfo,
JSAMPARRAY  scanlines,
JDIMENSION  max_lines 
)

Read decompressed image data by scanline. Maximum readable number of lines is the value of max_lines. The number of lines actually read is notified by the return value.

Note
jpeg_start_decompress must be completed before calling this API.
Parameters
[in,out]cinfoPointer to JPEG decompression object
[out]scanlinesPointer to buffer array
[in]max_linesArray size of scanlines
Returns
The number of lines actually read.

◆ jpeg_read_mcus()

JDIMENSION jpeg_read_mcus ( j_decompress_ptr  cinfo,
JSAMPARRAY  mcus,
JDIMENSION  max_lines,
JDIMENSION *  offset 
)

Read decoded data of some mcus from the JPEG decompressor.

Note
jpeg_start_decompress must be completed before calling this API. Currently, max_lines must be the size of one mcu.
Parameters
[in,out]cinfoPointer to JPEG decompression object
[out]mcusPointer to buffer array
[in]max_linesArray size of mcus
[out]offsetPosition of the read mcu from the top of image
Returns
The number of mcus actually read.

◆ jpeg_finish_decompress()

boolean jpeg_finish_decompress ( j_decompress_ptr  cinfo)

Finish JPEG decompression.

Parameters
[in]cinfoPointer to JPEG decompression object
Returns
return value meaning
FALSE Suspended due to lack of input data.
This value can be returned if application used jpeg_mem_src for JPEG data source input.
TRUE Success