-
Notifications
You must be signed in to change notification settings - Fork 1
/
mjpeg.h
302 lines (257 loc) · 5.45 KB
/
mjpeg.h
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/*
* mjpeg.h
*
* Created on: 2011/07/10
* Author: Tonsuke
*/
#ifndef MJPEG_H_
#define MJPEG_H_
#include "stm32f4xx_conf.h"
#include <stddef.h>
#include "fat.h"
#include "mpool.h"
MY_FILE fp_global;
struct {
int buf_type;
uint32_t frame_size;
}jpeg_read;
#define CMARK 0xA9
static uint8_t atomHasChild[] = {0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0 ,0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#define ATOM_ITEMS (sizeof(atomHasChild) / sizeof(atomHasChild[0]))
static const uint8_t atomTypeString[ATOM_ITEMS][5] =
{
"ftyp", // -
"wide", // -
"mdat", // -
"moov", // +
"mvhd", // -
"trak", // +
"tkhd", // -
"tapt", // +
"clef", // -
"prof", // -
"enof", // -
"edts", // +
"elst", // -
"mdia", // +
"mdhd", // -
"hdlr", // -
"minf", // +
"vmhd", // -
"smhd", // -
"dinf", // +
"dref", // -
"stbl", // +
"stsd", // -
"stts", // -
"stsc", // -
"stsz", // -
"stco", // -
"udta", // +
"free", // -
"skip", // -
"meta", // +
"load", // -
"iods", // -
"ilst", // +
"keys", // -
"data", // -
"trkn", // +
"disk", // +
"cpil", // +
"pgap", // +
"tmpo", // +
"gnre", // +
"covr", // -
{CMARK, 'n', 'a', 'm', '\0'}, // -
{CMARK, 'A', 'R', 'T', '\0'}, // -
{CMARK, 'a', 'l', 'b', '\0'}, // -
{CMARK, 'g', 'e', 'n', '\0'}, // -
{CMARK, 'd', 'a', 'y', '\0'}, // -
{CMARK, 't', 'o', 'o', '\0'}, // -
{CMARK, 'w', 'r', 't', '\0'}, // -
"----", // -
};
enum AtomEnum {
FTYP, // -
WIDE, // -
MDAT, // -
MOOV, // +
MVHD, // -
TRAK, // +
TKHD, // -
TAPT, // +
CLEF, // -
PROF, // -
ENOF, // -
EDTS, // +
ELST, // -
MDIA, // +
MDHD, // -
HDLR, // -
MINF, // +
VMHD, // -
SMHD, // -
DINF, // +
DREF, // -
STBL, // +
STSD, // -
STTS, // -
STSC, // -
STSZ, // -
STCO, // -
UDTA, // +
FREE, // -
SKIP, // -
META, // +
LOAD, // -
IODS, // -
ILST, // +
KEYS, // -
DATA, // -
TRKN, // +
DISK, // +
CPIL, // +
PGAP, // +
TMPO, // +
GNRE, // +
COVR, // -
CNAM, // -
CART, // -
CALB, // -
CGEN, // -
CDAY, // -
CTOO, // -
CWRT, // -
NONE, // -
};
volatile struct {
int8_t id, \
done, \
resynch, \
draw_icon;
uint32_t paused_chunk, \
resynch_entry;
} mjpeg_touch;
struct {
uint32_t *firstChunk, *prevChunk, *prevSamples, *samples, *totalSamples, *videoStcoCount;
MY_FILE *fp_video_stsc, *fp_video_stsz, *fp_video_stco, *fp_frame;
} pv_src;
struct {
uint32_t *firstChunk, *prevChunk, *prevSamples, *samples, *soundStcoCount;
MY_FILE *fp_sound_stsc, *fp_sound_stsz, *fp_sound_stco;
} ps_src;
struct{
uint32_t numEntry;
MY_FILE fp;
} sound_stts;
struct{
uint32_t numEntry;
MY_FILE fp;
} sound_stsc;
struct{
uint32_t sampleSize,
numEntry;
MY_FILE fp;
} sound_stsz;
struct{
uint32_t numEntry;
MY_FILE fp;
} sound_stco;
struct{
uint32_t numEntry;
MY_FILE fp;
} video_stts;
struct{
uint32_t numEntry;
MY_FILE fp;
} video_stsc;
struct{
uint32_t sampleSize,
numEntry;
MY_FILE fp;
} video_stsz;
struct{
uint32_t numEntry;
MY_FILE fp;
} video_stco;
typedef struct samples_struct{
uint32_t numEntry;
MY_FILE *fp;
} samples_struct;
typedef struct sound_flag{
uint32_t process, complete;
} sound_flag;
typedef struct video_flag{
uint32_t process, complete;
} video_flag;
typedef struct sound_format{
char audioFmtString[4];
uint8_t reserved[10];
uint16_t version,
revision,
vendor,
numChannel,
sampleSize,
complesionID,
packetSize,
sampleRate,
reserved1;
} sound_format;
typedef struct esds_format{
char esdsString[4];
// uint8_t reserved[22];
uint32_t maxBitrate, avgBitrate;
} esds_format;
typedef struct media_sound{
sound_flag flag;
sound_format format;
uint32_t timeScale,
duration;
} media_sound;
typedef struct media_video{
video_flag flag;
uint32_t timeScale,
duration;
int16_t width, height, frameRate, startPosX, startPosY;
char videoFmtString[5], videoCmpString[15], playJpeg;
} media_video;
volatile struct{
media_sound sound;
media_video video;
} media;
typedef struct {
int output_scanline, frame_size, rasters, buf_size;
uint16_t *p_raster;
} raw_video_typedef;
/* --- TIM1 SR Register ---*/
/* Alias word address of TIM1 SR UIF bit */
#define TIM1_SR_OFFSET (TIM1_BASE + 0x10)
#define TIM1_SR_UIF_BitNumber 0x00
#define TIM1_SR_UIF_BB (*(uint32_t *)(PERIPH_BB_BASE + (TIM1_SR_OFFSET * 32) + (TIM1_SR_UIF_BitNumber * 4)))
/* --- TIM3 CR1 Register ---*/
/* Alias word address of TIM3 CR1 CEN bit */
#define TIM3_CR1_OFFSET (TIM3_BASE + 0x00)
#define TIM3_CR1_CEN_BitNumber 0x00
#define TIM3_CR1_CEN_BB (*(uint32_t *)(PERIPH_BB_BASE + (TIM3_CR1_OFFSET * 32) + (TIM3_CR1_CEN_BitNumber * 4)))
/* --- TIM3 DIER Register ---*/
/* Alias word address of TIM3 DIER UIE bit */
#define TIM3_DIER_OFFSET (TIM3_BASE + 0x0C)
#define TIM3_DIER_UIE_BitNumber 0x00
#define TIM3_DIER_UIE_BB (*(uint32_t *)(PERIPH_BB_BASE + (TIM3_DIER_OFFSET * 32) + (TIM3_DIER_UIE_BitNumber * 4)))
/* --- TIM3 SR Register ---*/
/* Alias word address of TIM3 SR UIF bit */
#define TIM3_SR_OFFSET (TIM3_BASE + 0x10)
#define TIM3_SR_UIF_BitNumber 0x00
#define TIM3_SR_UIF_BB (*(uint32_t *)(PERIPH_BB_BASE + (TIM3_SR_OFFSET * 32) + (TIM3_SR_UIF_BitNumber * 4)))
extern uint32_t b2l(void* val, size_t t);
//inline uint32_t getAtomSize(void* atom);
extern int PlayMotionJpeg(int id);
/*
typedef struct
{
uint8_t mem[50000];
}ExtJpgMem_TypeDef;
#define JPG ((ExtJpgMem_TypeDef*)(0x600030C0))
*/
#endif /* MJPEG_H_ */