-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
368 lines (322 loc) · 10 KB
/
common.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/*
* sample-common.h
*
* Copyright (C) 2014 Ingenic Semiconductor Co.,Ltd
*/
#ifndef __SAMPLE_COMMON_H__
#define __SAMPLE_COMMON_H__
#include <imp/imp_common.h>
#include <imp/imp_osd.h>
#include <imp/imp_framesource.h>
#include <imp/imp_isp.h>
#include <imp/imp_system.h>
#include <imp/imp_encoder.h>
#include <unistd.h>
#ifdef __cplusplus
#if __cplusplus
extern "C"
{
#endif
#endif /* __cplusplus */
//#define SENSOR_FRAME_RATE_NUM 25
//#define SENSOR_FRAME_RATE_DEN 1
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
/*#define SENSOR_GC2053
//#define SENSOR_JXF37
#if defined SENSOR_AR0141
#define SENSOR_NAME "ar0141"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x10
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV7725
#define SENSOR_NAME "ov7725"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x21
#define SENSOR_WIDTH 640
#define SENSOR_HEIGHT 480
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 0
#elif defined SENSOR_OV9732
#define SENSOR_NAME "ov9732"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x36
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV9750
#define SENSOR_NAME "ov9750"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x36
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV9712
#define SENSOR_NAME "ov9712"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x30
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_GC1004
#define SENSOR_NAME "gc1004"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x3c
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_JXH42
#define SENSOR_NAME "jxh42"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x30
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 720
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_SC1035
#define SENSOR_NAME "sc1035"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x30
#define SENSOR_WIDTH 1280
#define SENSOR_HEIGHT 960
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV2710
#define SENSOR_NAME "ov2710"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x36
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV2735
#define SENSOR_NAME "ov2735"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x3c
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV2735B
#define SENSOR_NAME "ov2735b"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x3c
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_SC2135
#define SENSOR_NAME "sc2135"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x30
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_JXF22
#define SENSOR_NAME "jxf22"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x40
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_JXF23
#define SENSOR_NAME "jxf23"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x40
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_JXF37
#define SENSOR_NAME "jxf37"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x40
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_JXF28
#define SENSOR_NAME "jxf28"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x40
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_GC2053
#define SENSOR_NAME "gc2053"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x37
#define SENSOR_WIDTH 1920
#define SENSOR_HEIGHT 1080
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 1
#define CROP_EN 1
#elif defined SENSOR_OV4689
#define SENSOR_NAME "ov4689"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x36
#define SENSOR_WIDTH 2048
#define SENSOR_HEIGHT 1520
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 0
#define CROP_EN 1
#elif defined SENSOR_GC4653
#define SENSOR_NAME "gc4653"
#define SENSOR_CUBS_TYPE TX_SENSOR_CONTROL_INTERFACE_I2C
#define SENSOR_I2C_ADDR 0x29
#define SENSOR_WIDTH 2592
#define SENSOR_HEIGHT 1904
#define CHN0_EN 1
#define CHN1_EN 0
#define CHN2_EN 0
#define CHN3_EN 0
#define CROP_EN 1
#endif
#define SENSOR_WIDTH_SECOND 640
#define SENSOR_HEIGHT_SECOND 360
#define SENSOR_WIDTH_THIRD 1280
#define SENSOR_HEIGHT_THIRD 720*/
#define BITRATE_720P_Kbs 1000
#define NR_FRAMES_TO_SAVE 200
#define STREAM_BUFFER_SIZE (1 * 1024 * 1024)
#define ENC_VIDEO_CHANNEL 0
#define ENC_JPEG_CHANNEL 1
#define STREAM_FILE_PATH_PREFIX "/tmp"
#define SNAP_FILE_PATH_PREFIX "/tmp"
#define OSD_REGION_WIDTH 16
#define OSD_REGION_HEIGHT 34
#define OSD_REGION_WIDTH_SEC 8
#define OSD_REGION_HEIGHT_SEC 18
#define SLEEP_TIME 1
#define FS_CHN_NUM 4 //MIN 1,MAX 3
#define IVS_CHN_ID 3
#define CH0_INDEX 0
#define CH1_INDEX 1
#define CH2_INDEX 2
#define CH3_INDEX 3
#define CHN_ENABLE 1
#define CHN_DISABLE 0
/*#define SUPPORT_RGB555LE*/
struct chn_conf{
unsigned int index;//0 for main channel ,1 for second channel
unsigned int enable;
IMPEncoderProfile payloadType;
IMPFSChnAttr fs_chn_attr;
IMPCell framesource_chn;
IMPCell imp_encoder;
};
extern struct chn_conf chn[FS_CHN_NUM];
typedef struct {
uint8_t *streamAddr;
int streamLen;
}streamInfo;
typedef struct {
IMPEncoderEncType type;
IMPEncoderRcMode mode;
uint16_t frameRate;
uint16_t gopLength;
uint32_t targetBitrate;
uint32_t maxBitrate;
int16_t initQp;
int16_t minQp;
int16_t maxQp;
uint32_t maxPictureSize;
} encInfo;
#define CHN_NUM ARRAY_SIZE(chn)
int sample_system_init();
int sample_system_exit();
int sample_framesource_streamon();
int sample_framesource_streamoff();
int sample_framesource_ext_hsv_streamon();
int sample_framesource_ext_hsv_streamoff();
int sample_framesource_ext_rbga_streamon();
int sample_framesource_ext_rbga_streamoff();
int sample_framesource_init();
int sample_framesource_exit();
int sample_framesource_ext_hsv_init();
int sample_framesource_ext_hsv_exit();
int sample_framesource_ext_rbga_init();
int sample_framesource_ext_rbga_exit();
int sample_encoder_init();
int sample_jpeg_init();
int sample_encoder_exit(void);
int sample_jpeg_exit();
IMPRgnHandle *sample_osd_init(int grpNum);
int sample_osd_exit(IMPRgnHandle *prHandle,int grpNum);
int sample_get_frame();
int sample_get_video_stream();
int sample_get_video_stream_byfd();
int sample_get_jpeg_snap();
int sample_SetIRCUT(int enable);
void *sample_soft_photosensitive_ctrl(void *p);
int alcodec_encyuv_init(void **h, int picWidth, int picHight, void *info);
int alcodec_encyuv_encode(void *h, IMPFrameInfo frame, streamInfo *stream);
int alcodec_encyuv_deinit(void *h);
void initialize_chn();
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __SAMPLE_COMMON_H__ */