-
Notifications
You must be signed in to change notification settings - Fork 0
/
Converter.h
280 lines (237 loc) · 10.8 KB
/
Converter.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
/*
libcamera: An implementation of the library required by Android OS 3.2 so
it can access V4L2 devices as cameras.
(C) 2011 Eduardo José Tagle <[email protected]>
(C) 2011 RedScorpion
Based on several packages:
- luvcview: Sdl video Usb Video Class grabber
(C) 2005,2006,2007 Laurent Pinchart && Michel Xhaard
- spcaview
(C) 2003,2004,2005,2006 Michel Xhaard
- JPEG decoder from http://www.bootsplash.org/
(C) August 2001 by Michael Schroeder, <[email protected]>
- libcamera V4L for Android 2.2
(C) 2009 0xlab.org - http://0xlab.org/
(C) 2010 SpectraCore Technologies
Author: Venkat Raju <[email protected]>
Based on a code from http://code.google.com/p/android-m912/downloads/detail?name=v4l2_camera_v2.patch
- guvcview: http://guvcview.berlios.de
Paulo Assis <[email protected]>
Nobuhiro Iwamatsu <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONVERTER_H
#define CONVERTER_H
/* rotate 270 degree, assme width > height, and both are 4 multiplied, the output are the same rectangle, but only the square related with height contents data. */
void yuyv_rotate_270(uint8_t *dstyuyv270, uint8_t *dstyuv270, uint8_t *dstyuv, uint8_t *src, int width, int height);
/* Converters from camera format to android format */
void yuyv_to_yvu420sp(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
/* YV12: This is the format of choice for many software MPEG codecs. It comprises an NxM Y plane followed by (N/2)x(M/2) V and U planes. */
void yuyv_to_yvu420p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
/* YV12: This is the format of choice for many software MPEG codecs. It comprises an NxM Y plane followed by (N/2)x(M/2) U and V planes. */
void yuyv_to_yuv420p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
/* YV16: This format is basically a version of YV12 with higher chroma resolution. It comprises an NxM Y plane followed by (N/2)xM V and U planes. */
void yuyv_to_yvu422p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
/*convert yuyv to rgb24/32/565
* args:
* pyuv: pointer to buffer containing yuv data (yuyv)
* prgb: pointer to buffer containing rgb24 data
* width: picture width
* height: picture height
*/
void yuyv_to_rgb565 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
void yuyv_to_rgb24 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
void yuyv_to_rgb32 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
/*convert yuyv to bgr24/32/565
* args:
* pyuv: pointer to buffer containing yuv data (yuyv)
* prgb: pointer to buffer containing rgb24 data
* width: picture width
* height: picture height
*/
void yuyv_to_bgr565 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
void yuyv_to_bgr24 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
void yuyv_to_bgr32 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
/*convert yuv 420 planar (yu12) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yuv420 planar data frame
* width: picture width
* height: picture height
*/
void yuv420_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yvu 420 planar (yv12) to yuv 422 (yuyv)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yvu420 planar data frame
* width: picture width
* height: picture height
*/
void yvu420_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yuv 420 planar (uv interleaved) (nv12) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yuv420 (nv12) planar data frame
* width: picture width
* height: picture height
*/
void nv12_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yuv 420 planar (vu interleaved) (nv21) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yuv420 (nv21) planar data frame
* width: picture width
* height: picture height
*/
void nv21_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yuv 422 planar (uv interleaved) (nv16) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yuv422 (nv16) planar data frame
* width: picture width
* height: picture height
*/
void nv16_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yuv 422 planar (vu interleaved) (nv61) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yuv422 (nv61) planar data frame
* width: picture width
* height: picture height
*/
void nv61_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert y16 (grey) to yuyv (packed)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing y16 (grey) data frame
* width: picture width
* height: picture height
*/
void y16_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
/*convert yyuv to yuyv
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing a yyuv data frame
* width: picture width
* height: picture height
*/
void yyuv_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
/*convert uyvy (packed) to yuyv (packed)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing uyvy packed data frame
* width: picture width
* height: picture height
*/
void uyvy_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
/*convert yvyu (packed) to yuyv (packed)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing yvyu packed data frame
* width: picture width
* height: picture height
*/
void yvyu_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
/*convert yuv 411 packed (y41p) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing y41p data frame
* width: picture width
* height: picture height
*/
void y41p_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert yuv mono (grey) to yuv 422
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing grey (y only) data frame
* width: picture width
* height: picture height
*/
void grey_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
/*convert SPCA501 (s501) to yuv 422
* s501 |Y0..width..Y0|U..width/2..U|Y1..width..Y1|V..width/2..V|
* signed values (-128;+127) must be converted to unsigned (0; 255)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing s501 data frame
* width: picture width
* height: picture height
*/
void s501_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert SPCA505 (s505) to yuv 422
* s505 |Y0..width..Y0|Y1..width..Y1|U..width/2..U|V..width/2..V|
* signed values (-128;+127) must be converted to unsigned (0; 255)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing s501 data frame
* width: picture width
* height: picture height
*/
void s505_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert SPCA508 (s508) to yuv 422
* s508 |Y0..width..Y0|U..width/2..U|V..width/2..V|Y1..width..Y1|
* signed values (-128;+127) must be converted to unsigned (0; 255)
* args:
* framebuffer: pointer to frame buffer (yuyv)
* stride: stride of framebuffer
* src: pointer to temp buffer containing s501 data frame
* width: picture width
* height: picture height
*/
void s508_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
/*convert bayer raw data to rgb24
* args:
* pBay: pointer to buffer containing Raw bayer data data
* pRGB24: pointer to buffer containing rgb24 data
* width: picture width
* height: picture height
* pix_order: bayer pixel order (0=gb/rg 1=gr/bg 2=bg/gr 3=rg/bg)
*/
void bayer_to_rgb24(uint8_t *pBay, uint8_t *pRGB24, int width, int height, int pix_order);
/*convert rgb24 to yuyv
* args:
* src: pointer to buffer containing rgb24 data
* dst: pointer to buffer containing yuv data (yuyv)
* stride: stride of framebuffer
* width: picture width
* height: picture height
*/
void rgb_to_yuyv(uint8_t *dst, int dstStride, uint8_t *src, int srcStride, int width, int height);
/*convert bgr24 to yuyv
* args:
* src: pointer to buffer containing bgr24 data
* dst: pointer to buffer containing yuv data (yuyv)
* stride: stride of framebuffer
* width: picture width
* height: picture height
*/
void bgr_to_yuyv(uint8_t *dst, int dstStride, uint8_t *src, int srcStride, int width, int height);
/* yuyv_to_jpeg
* converts an input image in the YUYV format into a jpeg image and puts
* it in a memory buffer.
*/
int yuyv_to_jpeg(uint8_t* src, uint8_t* dst, int maxsize, int srcwidth, int srcheight, int srcstride, int quality);
#endif