Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
picojpeg.h
00001 //------------------------------------------------------------------------------ 00002 // picojpeg v1.0 - Public domain, Rich Geldreich <richgel99@gmail.com> 00003 //------------------------------------------------------------------------------ 00004 #ifndef PICOJPEG_H 00005 #define PICOJPEG_H 00006 00007 #ifdef __cplusplus 00008 extern "C" { 00009 #endif 00010 00011 // Error codes 00012 enum 00013 { 00014 PJPG_NO_MORE_BLOCKS = 1, 00015 PJPG_BAD_DHT_COUNTS, 00016 PJPG_BAD_DHT_INDEX, 00017 PJPG_BAD_DHT_MARKER, 00018 PJPG_BAD_DQT_MARKER, 00019 PJPG_BAD_DQT_TABLE, 00020 PJPG_BAD_PRECISION, 00021 PJPG_BAD_HEIGHT, 00022 PJPG_BAD_WIDTH, 00023 PJPG_TOO_MANY_COMPONENTS, 00024 PJPG_BAD_SOF_LENGTH, 00025 PJPG_BAD_VARIABLE_MARKER, 00026 PJPG_BAD_DRI_LENGTH, 00027 PJPG_BAD_SOS_LENGTH, 00028 PJPG_BAD_SOS_COMP_ID, 00029 PJPG_W_EXTRA_BYTES_BEFORE_MARKER, 00030 PJPG_NO_ARITHMITIC_SUPPORT, 00031 PJPG_UNEXPECTED_MARKER, 00032 PJPG_NOT_JPEG, 00033 PJPG_UNSUPPORTED_MARKER, 00034 PJPG_BAD_DQT_LENGTH, 00035 PJPG_TOO_MANY_BLOCKS, 00036 PJPG_UNDEFINED_QUANT_TABLE, 00037 PJPG_UNDEFINED_HUFF_TABLE, 00038 PJPG_NOT_SINGLE_SCAN, 00039 PJPG_UNSUPPORTED_COLORSPACE, 00040 PJPG_UNSUPPORTED_SAMP_FACTORS, 00041 PJPG_DECODE_ERROR, 00042 PJPG_BAD_RESTART_MARKER, 00043 PJPG_ASSERTION_ERROR, 00044 PJPG_BAD_SOS_SPECTRAL, 00045 PJPG_BAD_SOS_SUCCESSIVE, 00046 PJPG_STREAM_READ_ERROR, 00047 PJPG_NOTENOUGHMEM, 00048 PJPG_UNSUPPORTED_COMP_IDENT, 00049 PJPG_UNSUPPORTED_QUANT_TABLE, 00050 PJPG_UNSUPPORTED_MODE, 00051 }; 00052 00053 // Scan types - currently only GRAYSCALE, YH1V1, and YH2V2 are actually supported. 00054 typedef enum 00055 { 00056 PJPG_GRAYSCALE, 00057 PJPG_YH1V1, 00058 PJPG_YH2V1, 00059 PJPG_YH1V2, 00060 PJPG_YH2V2 00061 } pjpeg_scan_type_t; 00062 00063 typedef struct 00064 { 00065 // Image resolution 00066 int m_width; 00067 int m_height; 00068 // Number of components (1 or 3) 00069 int m_comps; 00070 // Total number of minimum coded units (MCU's) per row/col. 00071 int m_MCUSPerRow; 00072 int m_MCUSPerCol; 00073 // Scan type 00074 pjpeg_scan_type_t m_scanType; 00075 // MCU width/height in pixels 00076 int m_MCUWidth; 00077 int m_MCUHeight; 00078 // Pointers to internal MCU pixel component buffers. 00079 // These buffers Will be filled with pixels each time pjpegDecodeMCU() is called successfully. 00080 // Each MCU consists of (m_MCUWidth/8)*(m_MCUHeight/8) blocks (currently either 1 for greyscale/no subsampling, or 4 for H2V2 sampling factors), where each block is a contiguous array of 64 (8x8) bytes. 00081 // For greyscale images, only the values in m_pMCUBufR are valid. 00082 unsigned char *m_pMCUBufR; 00083 unsigned char *m_pMCUBufG; 00084 unsigned char *m_pMCUBufB; 00085 } pjpeg_image_info_t; 00086 00087 typedef unsigned char (*pjpeg_need_bytes_callback_t)(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data); 00088 00089 // Initializes the decompressor. Returns 0 on success, or one of the above error codes on failure. 00090 // pNeed_bytes_callback will be called to fill the decompressor's internal input buffer. 00091 // Not thread safe. 00092 unsigned char pjpeg_decode_init(pjpeg_image_info_t *pInfo, pjpeg_need_bytes_callback_t pNeed_bytes_callback, void *pCallback_data); 00093 00094 // Decompresses the file's next MCU. Returns 0 on success, PJPG_NO_MORE_BLOCKS if no more blocks are available, or an error code. 00095 // Must be called a total of m_MCUSPerRow*m_MCUSPerCol times to completely decompress the image. 00096 unsigned char pjpeg_decode_mcu(void); 00097 00098 #ifdef __cplusplus 00099 } 00100 #endif 00101 00102 #endif // PICOJPEG_H
Generated on Wed Jul 13 2022 18:08:25 by
1.7.2