Final

Dependencies:   DebounceIn NokiaLCD WiflyInterface mbed

Fork of Websocket_Wifly_HelloWorld by Samuel Mokrani

Committer:
Ifrah
Date:
Fri Dec 14 15:40:21 2012 +0000
Revision:
5:c4c66c630011
Parent:
3:3c7906d60f89
Final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ifrah 3:3c7906d60f89 1 //------------------------------------------------------------------------------
Ifrah 3:3c7906d60f89 2 // picojpeg v1.0 - Public domain, Rich Geldreich <richgel99@gmail.com>
Ifrah 3:3c7906d60f89 3 //------------------------------------------------------------------------------
Ifrah 3:3c7906d60f89 4 #ifndef PICOJPEG_H
Ifrah 3:3c7906d60f89 5 #define PICOJPEG_H
Ifrah 3:3c7906d60f89 6
Ifrah 3:3c7906d60f89 7 #ifdef __cplusplus
Ifrah 3:3c7906d60f89 8 extern "C" {
Ifrah 3:3c7906d60f89 9 #endif
Ifrah 3:3c7906d60f89 10
Ifrah 3:3c7906d60f89 11 // Error codes
Ifrah 3:3c7906d60f89 12 enum
Ifrah 3:3c7906d60f89 13 {
Ifrah 3:3c7906d60f89 14 PJPG_NO_MORE_BLOCKS = 1,
Ifrah 3:3c7906d60f89 15 PJPG_BAD_DHT_COUNTS,
Ifrah 3:3c7906d60f89 16 PJPG_BAD_DHT_INDEX,
Ifrah 3:3c7906d60f89 17 PJPG_BAD_DHT_MARKER,
Ifrah 3:3c7906d60f89 18 PJPG_BAD_DQT_MARKER,
Ifrah 3:3c7906d60f89 19 PJPG_BAD_DQT_TABLE,
Ifrah 3:3c7906d60f89 20 PJPG_BAD_PRECISION,
Ifrah 3:3c7906d60f89 21 PJPG_BAD_HEIGHT,
Ifrah 3:3c7906d60f89 22 PJPG_BAD_WIDTH,
Ifrah 3:3c7906d60f89 23 PJPG_TOO_MANY_COMPONENTS,
Ifrah 3:3c7906d60f89 24 PJPG_BAD_SOF_LENGTH,
Ifrah 3:3c7906d60f89 25 PJPG_BAD_VARIABLE_MARKER,
Ifrah 3:3c7906d60f89 26 PJPG_BAD_DRI_LENGTH,
Ifrah 3:3c7906d60f89 27 PJPG_BAD_SOS_LENGTH,
Ifrah 3:3c7906d60f89 28 PJPG_BAD_SOS_COMP_ID,
Ifrah 3:3c7906d60f89 29 PJPG_W_EXTRA_BYTES_BEFORE_MARKER,
Ifrah 3:3c7906d60f89 30 PJPG_NO_ARITHMITIC_SUPPORT,
Ifrah 3:3c7906d60f89 31 PJPG_UNEXPECTED_MARKER,
Ifrah 3:3c7906d60f89 32 PJPG_NOT_JPEG,
Ifrah 3:3c7906d60f89 33 PJPG_UNSUPPORTED_MARKER,
Ifrah 3:3c7906d60f89 34 PJPG_BAD_DQT_LENGTH,
Ifrah 3:3c7906d60f89 35 PJPG_TOO_MANY_BLOCKS,
Ifrah 3:3c7906d60f89 36 PJPG_UNDEFINED_QUANT_TABLE,
Ifrah 3:3c7906d60f89 37 PJPG_UNDEFINED_HUFF_TABLE,
Ifrah 3:3c7906d60f89 38 PJPG_NOT_SINGLE_SCAN,
Ifrah 3:3c7906d60f89 39 PJPG_UNSUPPORTED_COLORSPACE,
Ifrah 3:3c7906d60f89 40 PJPG_UNSUPPORTED_SAMP_FACTORS,
Ifrah 3:3c7906d60f89 41 PJPG_DECODE_ERROR,
Ifrah 3:3c7906d60f89 42 PJPG_BAD_RESTART_MARKER,
Ifrah 3:3c7906d60f89 43 PJPG_ASSERTION_ERROR,
Ifrah 3:3c7906d60f89 44 PJPG_BAD_SOS_SPECTRAL,
Ifrah 3:3c7906d60f89 45 PJPG_BAD_SOS_SUCCESSIVE,
Ifrah 3:3c7906d60f89 46 PJPG_STREAM_READ_ERROR,
Ifrah 3:3c7906d60f89 47 PJPG_NOTENOUGHMEM,
Ifrah 3:3c7906d60f89 48 PJPG_UNSUPPORTED_COMP_IDENT,
Ifrah 3:3c7906d60f89 49 PJPG_UNSUPPORTED_QUANT_TABLE,
Ifrah 3:3c7906d60f89 50 PJPG_UNSUPPORTED_MODE,
Ifrah 3:3c7906d60f89 51 };
Ifrah 3:3c7906d60f89 52
Ifrah 3:3c7906d60f89 53 // Scan types - currently only GRAYSCALE, YH1V1, and YH2V2 are actually supported.
Ifrah 3:3c7906d60f89 54 typedef enum
Ifrah 3:3c7906d60f89 55 {
Ifrah 3:3c7906d60f89 56 PJPG_GRAYSCALE,
Ifrah 3:3c7906d60f89 57 PJPG_YH1V1,
Ifrah 3:3c7906d60f89 58 PJPG_YH2V1,
Ifrah 3:3c7906d60f89 59 PJPG_YH1V2,
Ifrah 3:3c7906d60f89 60 PJPG_YH2V2
Ifrah 3:3c7906d60f89 61 } pjpeg_scan_type_t;
Ifrah 3:3c7906d60f89 62
Ifrah 3:3c7906d60f89 63 typedef struct
Ifrah 3:3c7906d60f89 64 {
Ifrah 3:3c7906d60f89 65 // Image resolution
Ifrah 3:3c7906d60f89 66 int m_width;
Ifrah 3:3c7906d60f89 67 int m_height;
Ifrah 3:3c7906d60f89 68 // Number of components (1 or 3)
Ifrah 3:3c7906d60f89 69 int m_comps;
Ifrah 3:3c7906d60f89 70 // Total number of minimum coded units (MCU's) per row/col.
Ifrah 3:3c7906d60f89 71 int m_MCUSPerRow;
Ifrah 3:3c7906d60f89 72 int m_MCUSPerCol;
Ifrah 3:3c7906d60f89 73 // Scan type
Ifrah 3:3c7906d60f89 74 pjpeg_scan_type_t m_scanType;
Ifrah 3:3c7906d60f89 75 // MCU width/height in pixels
Ifrah 3:3c7906d60f89 76 int m_MCUWidth;
Ifrah 3:3c7906d60f89 77 int m_MCUHeight;
Ifrah 3:3c7906d60f89 78 // Pointers to internal MCU pixel component buffers.
Ifrah 3:3c7906d60f89 79 // These buffers Will be filled with pixels each time pjpegDecodeMCU() is called successfully.
Ifrah 3:3c7906d60f89 80 // 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.
Ifrah 3:3c7906d60f89 81 // For greyscale images, only the values in m_pMCUBufR are valid.
Ifrah 3:3c7906d60f89 82 unsigned char *m_pMCUBufR;
Ifrah 3:3c7906d60f89 83 unsigned char *m_pMCUBufG;
Ifrah 3:3c7906d60f89 84 unsigned char *m_pMCUBufB;
Ifrah 3:3c7906d60f89 85 } pjpeg_image_info_t;
Ifrah 3:3c7906d60f89 86
Ifrah 3:3c7906d60f89 87 typedef unsigned char (*pjpeg_need_bytes_callback_t)(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data);
Ifrah 3:3c7906d60f89 88
Ifrah 3:3c7906d60f89 89 // Initializes the decompressor. Returns 0 on success, or one of the above error codes on failure.
Ifrah 3:3c7906d60f89 90 // pNeed_bytes_callback will be called to fill the decompressor's internal input buffer.
Ifrah 3:3c7906d60f89 91 // Not thread safe.
Ifrah 3:3c7906d60f89 92 unsigned char pjpeg_decode_init(pjpeg_image_info_t *pInfo, pjpeg_need_bytes_callback_t pNeed_bytes_callback, void *pCallback_data);
Ifrah 3:3c7906d60f89 93
Ifrah 3:3c7906d60f89 94 // Decompresses the file's next MCU. Returns 0 on success, PJPG_NO_MORE_BLOCKS if no more blocks are available, or an error code.
Ifrah 3:3c7906d60f89 95 // Must be called a total of m_MCUSPerRow*m_MCUSPerCol times to completely decompress the image.
Ifrah 3:3c7906d60f89 96 unsigned char pjpeg_decode_mcu(void);
Ifrah 3:3c7906d60f89 97
Ifrah 3:3c7906d60f89 98 #ifdef __cplusplus
Ifrah 3:3c7906d60f89 99 }
Ifrah 3:3c7906d60f89 100 #endif
Ifrah 3:3c7906d60f89 101
Ifrah 3:3c7906d60f89 102 #endif // PICOJPEG_H