-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJPEGDecoder.h
More file actions
123 lines (84 loc) · 2.09 KB
/
JPEGDecoder.h
File metadata and controls
123 lines (84 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
JPEGDecoder.h
JPEG Decoder for Arduino
Public domain, Makoto Kurauchi <http://yushakobo.jp>
adapted by Frederic Plante for ESP8266
https://github.com/fredericplante/JPEGDecoder
*/
#ifndef JPEGDECODER_H
#define JPEGDECODER_H
#include "User_Config.h"
#ifdef ESP8266
#include "arduino.h"
#else
#include "Arduino.h"
#endif
#ifdef USE_SPIFFS
#include <FS.h>
#endif
#ifdef USE_SD_CARD
#ifdef __AVR__
#include <SD.h>
#else
#include <SdFat.h>
#endif
#endif
#include "picojpeg.h"
// #define DEBUG
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
typedef unsigned char uint8;
typedef unsigned int uint;
class JPEGDecoder {
private:
#ifdef USE_SERIAL
#else
File g_pInFile;
#endif
pjpeg_scan_type_t scan_type;
pjpeg_image_info_t image_info;
int is_available;
int mcu_x;
int mcu_y;
uint g_nInFileSize;
uint g_nInFileOfs;
uint row_pitch;
uint decoded_width, decoded_height;
uint row_blocks_per_mcu, col_blocks_per_mcu;
uint8 status;
uint8 array_jpg;
uint8_t* jpg_data;
static uint8 pjpeg_callback(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data);
uint8 pjpeg_need_bytes_callback(unsigned char* pBuf, unsigned char buf_size, unsigned char *pBytes_actually_read, void *pCallback_data);
int decode_mcu(void);
int decodeCommon(void);
public:
uint16_t *pImage;
JPEGDecoder *thisPtr;
int width;
int height;
int comps;
int MCUSPerRow;
int MCUSPerCol;
pjpeg_scan_type_t scanType;
int MCUWidth;
int MCUHeight;
int MCUx;
int MCUy;
JPEGDecoder();
~JPEGDecoder();
int available(void);
int read(void);
int decode (char* pFilename, unsigned char pReduce);
int decodeFile (char* pFilename, unsigned char pReduce);
int decodeArray(const uint8_t array[], uint32_t array_size, unsigned char pReduce);
int decodeFile (char* pFilename);
int decodeArray(const uint8_t array[], uint32_t array_size);
void abort(void);
};
extern JPEGDecoder JpegDec;
#endif