blob: 0bbab6ced80ba7d146e57ffb3537a860898c7db8 [file] [log] [blame]
Chih-Wei Huang0d92eda2012-02-07 16:55:49 +08001/*
2 libcamera: An implementation of the library required by Android OS 3.2 so
3 it can access V4L2 devices as cameras.
4
Chih-Wei Huangd5590eb2019-02-26 17:48:45 +08005 (C) 2011 Eduardo José Tagle <ejtagle@tutopia.com>
Chih-Wei Huang0d92eda2012-02-07 16:55:49 +08006 (C) 2011 RedScorpion
7
8 Based on several packages:
9 - luvcview: Sdl video Usb Video Class grabber
10 (C) 2005,2006,2007 Laurent Pinchart && Michel Xhaard
11
12 - spcaview
13 (C) 2003,2004,2005,2006 Michel Xhaard
14
15 - JPEG decoder from http://www.bootsplash.org/
16 (C) August 2001 by Michael Schroeder, <mls@suse.de>
17
18 - libcamera V4L for Android 2.2
19 (C) 2009 0xlab.org - http://0xlab.org/
20 (C) 2010 SpectraCore Technologies
21 Author: Venkat Raju <codredruids@spectracoretech.com>
22 Based on a code from http://code.google.com/p/android-m912/downloads/detail?name=v4l2_camera_v2.patch
23
24 - guvcview: http://guvcview.berlios.de
25 Paulo Assis <pj.assis@gmail.com>
26 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
27
28 This program is free software: you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation, either version 3 of the License, or
31 (at your option) any later version.
32
33 This program is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details.
37
38 You should have received a copy of the GNU General Public License
39 along with this program. If not, see <http://www.gnu.org/licenses/>.
40
41 */
42
43
44#ifndef CONVERTER_H
45#define CONVERTER_H
46
47/* Converters from camera format to android format */
48void yuyv_to_yvu420sp(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
49
50/* 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. */
51void yuyv_to_yvu420p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
52
53/* 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. */
54void yuyv_to_yuv420p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
55
56/* 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. */
57void yuyv_to_yvu422p(uint8_t *dst,int dstStride, int dstHeight, uint8_t *src, int srcStride, int width, int height);
58
59
60/*convert yuyv to rgb24/32/565
61* args:
62* pyuv: pointer to buffer containing yuv data (yuyv)
63* prgb: pointer to buffer containing rgb24 data
64* width: picture width
65* height: picture height
66*/
67void yuyv_to_rgb565 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
68void yuyv_to_rgb24 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
69void yuyv_to_rgb32 (uint8_t *pyuv, int pyuvstride, uint8_t *prgb,int prgbstride, int width, int height);
70
71
72/*convert yuyv to bgr24/32/565
73* args:
74* pyuv: pointer to buffer containing yuv data (yuyv)
75* prgb: pointer to buffer containing rgb24 data
76* width: picture width
77* height: picture height
78*/
79void yuyv_to_bgr565 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
80void yuyv_to_bgr24 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
81void yuyv_to_bgr32 (uint8_t *pyuv, int pyuvstride, uint8_t *pbgr, int pbgrstride, int width, int height);
82
83
84/*convert yuv 420 planar (yu12) to yuv 422
85* args:
86* framebuffer: pointer to frame buffer (yuyv)
87* stride: stride of framebuffer
88* src: pointer to temp buffer containing yuv420 planar data frame
89* width: picture width
90* height: picture height
91*/
92void yuv420_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
93
94/*convert yvu 420 planar (yv12) to yuv 422 (yuyv)
95* args:
96* framebuffer: pointer to frame buffer (yuyv)
97* stride: stride of framebuffer
98* src: pointer to temp buffer containing yvu420 planar data frame
99* width: picture width
100* height: picture height
101*/
102void yvu420_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
103
104/*convert yuv 420 planar (uv interleaved) (nv12) to yuv 422
105* args:
106* framebuffer: pointer to frame buffer (yuyv)
107* stride: stride of framebuffer
108* src: pointer to temp buffer containing yuv420 (nv12) planar data frame
109* width: picture width
110* height: picture height
111*/
112void nv12_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
113
114/*convert yuv 420 planar (vu interleaved) (nv21) to yuv 422
115* args:
116* framebuffer: pointer to frame buffer (yuyv)
117* stride: stride of framebuffer
118* src: pointer to temp buffer containing yuv420 (nv21) planar data frame
119* width: picture width
120* height: picture height
121*/
122void nv21_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
123
124/*convert yuv 422 planar (uv interleaved) (nv16) to yuv 422
125* args:
126* framebuffer: pointer to frame buffer (yuyv)
127* stride: stride of framebuffer
128* src: pointer to temp buffer containing yuv422 (nv16) planar data frame
129* width: picture width
130* height: picture height
131*/
132void nv16_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
133
134/*convert yuv 422 planar (vu interleaved) (nv61) to yuv 422
135* args:
136* framebuffer: pointer to frame buffer (yuyv)
137* stride: stride of framebuffer
138* src: pointer to temp buffer containing yuv422 (nv61) planar data frame
139* width: picture width
140* height: picture height
141*/
142void nv61_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
143
144/*convert y16 (grey) to yuyv (packed)
145* args:
146* framebuffer: pointer to frame buffer (yuyv)
147* stride: stride of framebuffer
148* src: pointer to temp buffer containing y16 (grey) data frame
149* width: picture width
150* height: picture height
151*/
152void y16_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
153
154/*convert yyuv to yuyv
155* args:
156* framebuffer: pointer to frame buffer (yuyv)
157* stride: stride of framebuffer
158* src: pointer to temp buffer containing a yyuv data frame
159* width: picture width
160* height: picture height
161*/
162void yyuv_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
163
164/*convert uyvy (packed) to yuyv (packed)
165* args:
166* framebuffer: pointer to frame buffer (yuyv)
167* stride: stride of framebuffer
168* src: pointer to temp buffer containing uyvy packed data frame
169* width: picture width
170* height: picture height
171*/
172void uyvy_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
173
174/*convert yvyu (packed) to yuyv (packed)
175* args:
176* framebuffer: pointer to frame buffer (yuyv)
177* stride: stride of framebuffer
178* src: pointer to temp buffer containing yvyu packed data frame
179* width: picture width
180* height: picture height
181*/
182void yvyu_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
183
184/*convert yuv 411 packed (y41p) to yuv 422
185* args:
186* framebuffer: pointer to frame buffer (yuyv)
187* stride: stride of framebuffer
188* src: pointer to temp buffer containing y41p data frame
189* width: picture width
190* height: picture height
191*/
192void y41p_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
193
194/*convert yuv mono (grey) to yuv 422
195* args:
196* framebuffer: pointer to frame buffer (yuyv)
197* stride: stride of framebuffer
198* src: pointer to temp buffer containing grey (y only) data frame
199* width: picture width
200* height: picture height
201*/
202void grey_to_yuyv (uint8_t *dst,int dstStride, uint8_t *src,int srcStride, int width, int height);
203
204/*convert SPCA501 (s501) to yuv 422
205* s501 |Y0..width..Y0|U..width/2..U|Y1..width..Y1|V..width/2..V|
206* signed values (-128;+127) must be converted to unsigned (0; 255)
207* args:
208* framebuffer: pointer to frame buffer (yuyv)
209* stride: stride of framebuffer
210* src: pointer to temp buffer containing s501 data frame
211* width: picture width
212* height: picture height
213*/
214void s501_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
215
216/*convert SPCA505 (s505) to yuv 422
217* s505 |Y0..width..Y0|Y1..width..Y1|U..width/2..U|V..width/2..V|
218* signed values (-128;+127) must be converted to unsigned (0; 255)
219* args:
220* framebuffer: pointer to frame buffer (yuyv)
221* stride: stride of framebuffer
222* src: pointer to temp buffer containing s501 data frame
223* width: picture width
224* height: picture height
225*/
226void s505_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
227
228/*convert SPCA508 (s508) to yuv 422
229* s508 |Y0..width..Y0|U..width/2..U|V..width/2..V|Y1..width..Y1|
230* signed values (-128;+127) must be converted to unsigned (0; 255)
231* args:
232* framebuffer: pointer to frame buffer (yuyv)
233* stride: stride of framebuffer
234* src: pointer to temp buffer containing s501 data frame
235* width: picture width
236* height: picture height
237*/
238void s508_to_yuyv(uint8_t *dst,int dstStride, uint8_t *src, int width, int height);
239
240/*convert bayer raw data to rgb24
241* args:
242* pBay: pointer to buffer containing Raw bayer data data
243* pRGB24: pointer to buffer containing rgb24 data
244* width: picture width
245* height: picture height
246* pix_order: bayer pixel order (0=gb/rg 1=gr/bg 2=bg/gr 3=rg/bg)
247*/
248void bayer_to_rgb24(uint8_t *pBay, uint8_t *pRGB24, int width, int height, int pix_order);
249
250/*convert rgb24 to yuyv
251* args:
252* src: pointer to buffer containing rgb24 data
253* dst: pointer to buffer containing yuv data (yuyv)
254* stride: stride of framebuffer
255* width: picture width
256* height: picture height
257*/
258void rgb_to_yuyv(uint8_t *dst, int dstStride, uint8_t *src, int srcStride, int width, int height);
259
260/*convert bgr24 to yuyv
261* args:
262* src: pointer to buffer containing bgr24 data
263* dst: pointer to buffer containing yuv data (yuyv)
264* stride: stride of framebuffer
265* width: picture width
266* height: picture height
267*/
268void bgr_to_yuyv(uint8_t *dst, int dstStride, uint8_t *src, int srcStride, int width, int height);
269
270/* yuyv_to_jpeg
271 * converts an input image in the YUYV format into a jpeg image and puts
272 * it in a memory buffer.
273 */
274int yuyv_to_jpeg(uint8_t* src, uint8_t* dst, int maxsize, int srcwidth, int srcheight, int srcstride, int quality);
275
276
277#endif