1 /*
2  *
3  * Copyright 2012 Samsung Electronics S.LSI Co. LTD
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * @file    swconverter.h
20  * @brief   Exynos_OMX specific define. It support MFC's tiled format.
21  *   NV12T(tiled) layout:
22  *   Each element is not pixel.
23  *   MFC 5.x : It is 64x32 pixel block.
24  *   MFC 6.x : It is 16x16 pixel block.
25  *   uv pixel block is interleaved as u v u v u v ...
26  *   y1    y2    y7    y8    y9    y10   y15   y16
27  *   y3    y4    y5    y6    y11   y12   y13   y14
28  *   y17   y18   y23   y24   y25   y26   y31   y32
29  *   y19   y20   y21   y22   y27   y28   y29   y30
30  *   uv1   uv2   uv7   uv8   uv9   uv10  uv15  uv16
31  *   uv3   uv4   uv5   uv6   uv11  uv12  uv13  uv14
32  *   YUV420Planar(linear) layout:
33  *   Each element is not pixel. It is 64x32 pixel block.
34  *   y1    y2    y3    y4    y5    y6    y7    y8
35  *   y9    y10   y11   y12   y13   y14   y15   y16
36  *   y17   y18   y19   y20   y21   y22   y23   y24
37  *   y25   y26   y27   y28   y29   y30   y31   y32
38  *   u1    u2    u3    u4    u5    u6    u7    u8
39  *   v1    v2    v3    v4    v5    v6    v7    v8
40  *   YUV420Semiplanar(linear) layout:
41  *   Each element is not pixel. It is 64x32 pixel block.
42  *   uv pixel block is interleaved as u v u v u v ...
43  *   y1    y2    y3    y4    y5    y6    y7    y8
44  *   y9    y10   y11   y12   y13   y14   y15   y16
45  *   y17   y18   y19   y20   y21   y22   y23   y24
46  *   y25   y26   y27   y28   y29   y30   y31   y32
47  *   uv1   uv2   uv3   uv4   uv5   uv6   uv7   uv8
48  *   uv9   uv10  uv11  uv12  uv13  uv14  uv15  uv16
49  * @author  ShinWon Lee (shinwon.lee@samsung.com)
50  * @version 1.0
51  * @history
52  *   2012.02.01 : Create
53  */
54 
55 #ifndef SW_CONVERTOR_H_
56 #define SW_CONVERTOR_H_
57 
58 /*--------------------------------------------------------------------------------*/
59 /* Format Conversion API                                                          */
60 /*--------------------------------------------------------------------------------*/
61 /*
62  * C code only
63  * De-interleaves src to dest1, dest2
64  *
65  * @param dest1
66  *   Address of de-interleaved data[out]
67  *
68  * @param dest2
69  *   Address of de-interleaved data[out]
70  *
71  * @param src
72  *   Address of interleaved data[in]
73  *
74  * @param src_size
75  *   Size of interleaved data[in]
76  */
77 void csc_deinterleave_memcpy(
78     unsigned char *dest1,
79     unsigned char *dest2,
80     unsigned char *src,
81     unsigned int src_size);
82 
83 /*
84  * C code or Neon
85  * Interleaves src1, src2 to dest
86  *
87  * @param dest
88  *   Address of interleaved data[out]
89  *
90  * @param src1
91  *   Address of de-interleaved data[in]
92  *
93  * @param src2
94  *   Address of de-interleaved data[in]
95  *
96  * @param src_size
97  *   Size of de-interleaved data[in]
98  */
99 void csc_interleave_memcpy(
100     unsigned char *dest,
101     unsigned char *src1,
102     unsigned char *src2,
103     unsigned int src_size);
104 
105 /*
106  * C code or Neon
107  * Converts tiled data to linear
108  * 1. y of nv12t to y of yuv420p
109  * 2. y of nv12t to y of yuv420s
110  *
111  * @param dst
112  *   y address of yuv420[out]
113  *
114  * @param src
115  *   y address of nv12t[in]
116  *
117  * @param yuv420_width
118  *   real width of yuv420[in]
119  *   it should be even
120  *
121  * @param yuv420_height
122  *   real height of yuv420[in]
123  *   it should be even.
124  *
125  */
126 void csc_tiled_to_linear_y(
127     unsigned char *y_dst,
128     unsigned char *y_src,
129     unsigned int width,
130     unsigned int height);
131 
132 /*
133  * C code or Neon
134  * Converts tiled data to linear
135  * 1. uv of nv12t to y of yuv420s
136  *
137  * @param dst
138  *   uv address of yuv420s[out]
139  *
140  * @param src
141  *   uv address of nv12t[in]
142  *
143  * @param yuv420_width
144  *   real width of yuv420s[in]
145  *
146  * @param yuv420_height
147  *   real height of yuv420s[in]
148  *
149  */
150 void csc_tiled_to_linear_uv(
151     unsigned char *uv_dst,
152     unsigned char *uv_src,
153     unsigned int width,
154     unsigned int height);
155 
156 /*
157  * C code or Neon
158  * Converts tiled data to linear
159  * 1. uv of nt12t to uv of yuv420p
160  *
161  * @param u_dst
162  *   u address of yuv420p[out]
163  *
164  * @param v_dst
165  *   v address of yuv420p[out]
166  *
167  * @param uv_src
168  *   uv address of nt12t[in]
169  *
170  * @param yuv420_width
171  *   real width of yuv420p[in]
172  *
173  * @param yuv420_height
174  *   real height of yuv420p[in]
175  */
176 void csc_tiled_to_linear_uv_deinterleave(
177     unsigned char *u_dst,
178     unsigned char *v_dst,
179     unsigned char *uv_src,
180     unsigned int width,
181     unsigned int height);
182 
183 /*
184  * Neon only
185  * Converts linear data to tiled
186  * 1. y of yuv420 to y of nv12t
187  *
188  * @param dst
189  *   y address of nv12t[out]
190  *
191  * @param src
192  *   y address of yuv420[in]
193  *
194  * @param yuv420_width
195  *   real width of yuv420[in]
196  *   it should be even
197  *
198  * @param yuv420_height
199  *   real height of yuv420[in]
200  *   it should be even.
201  *
202  */
203 void csc_linear_to_tiled_y(
204     unsigned char *y_dst,
205     unsigned char *y_src,
206     unsigned int width,
207     unsigned int height);
208 
209 /*
210  * Neon only
211  * Converts and interleaves linear data to tiled
212  * 1. uv of nv12t to uv of yuv420
213  *
214  * @param dst
215  *   uv address of nv12t[out]
216  *
217  * @param src
218  *   u address of yuv420[in]
219  *
220  * @param src
221  *   v address of yuv420[in]
222  *
223  * @param yuv420_width
224  *   real width of yuv420[in]
225  *
226  * @param yuv420_height
227  *   real height of yuv420[in]
228  *
229  */
230 void csc_linear_to_tiled_uv(
231     unsigned char *uv_dst,
232     unsigned char *u_src,
233     unsigned char *v_src,
234     unsigned int width,
235     unsigned int height);
236 
237 /*
238  * C code only
239  * Converts RGB565 to YUV420P
240  *
241  * @param y_dst
242  *   Y plane address of YUV420P[out]
243  *
244  * @param u_dst
245  *   U plane address of YUV420P[out]
246  *
247  * @param v_dst
248  *   V plane address of YUV420P[out]
249  *
250  * @param rgb_src
251  *   Address of RGB565[in]
252  *
253  * @param width
254  *   Width of RGB565[in]
255  *
256  * @param height
257  *   Height of RGB565[in]
258  */
259 void csc_RGB565_to_YUV420P(
260     unsigned char *y_dst,
261     unsigned char *u_dst,
262     unsigned char *v_dst,
263     unsigned char *rgb_src,
264     int width,
265     int height);
266 
267 /*
268  * C code only
269  * Converts RGB565 to YUV420SP
270  *
271  * @param y_dst
272  *   Y plane address of YUV420SP[out]
273  *
274  * @param uv_dst
275  *   UV plane address of YUV420SP[out]
276  *
277  * @param rgb_src
278  *   Address of RGB565[in]
279  *
280  * @param width
281  *   Width of RGB565[in]
282  *
283  * @param height
284  *   Height of RGB565[in]
285  */
286 void csc_RGB565_to_YUV420SP(
287     unsigned char *y_dst,
288     unsigned char *uv_dst,
289     unsigned char *rgb_src,
290     int width,
291     int height);
292 
293 /*
294  * C code only
295  * Converts BGRA8888 to YUV420P
296  *
297  * @param y_dst
298  *   Y plane address of YUV420P[out]
299  *
300  * @param u_dst
301  *   U plane address of YUV420P[out]
302  *
303  * @param v_dst
304  *   V plane address of YUV420P[out]
305  *
306  * @param rgb_src
307  *   Address of BGRA8888[in]
308  *
309  * @param width
310  *   Width of BGRA8888[in]
311  *
312  * @param height
313  *   Height of BGRA8888[in]
314  */
315 void csc_BGRA8888_to_YUV420P(
316     unsigned char *y_dst,
317     unsigned char *u_dst,
318     unsigned char *v_dst,
319     unsigned char *rgb_src,
320     unsigned int width,
321     unsigned int height);
322 
323 /*
324  * C code or Neon
325  * Converts BGRA8888 to YUV420SP
326  *
327  * @param y_dst
328  *   Y plane address of YUV420SP[out]
329  *
330  * @param uv_dst
331  *   UV plane address of YUV420SP[out]
332  *
333  * @param rgb_src
334  *   Address of BGRA8888[in]
335  *
336  * @param width
337  *   Width of BGRA8888[in]
338  *
339  * @param height
340  *   Height of BGRA8888[in]
341  */
342 void csc_BGRA8888_to_YUV420SP(
343     unsigned char *y_dst,
344     unsigned char *uv_dst,
345     unsigned char *rgb_src,
346     unsigned int width,
347     unsigned int height);
348 
349 /*
350  * C code only
351  * Converts RGBA8888 to YUV420P
352  *
353  * @param y_dst
354  *   Y plane address of YUV420P[out]
355  *
356  * @param u_dst
357  *   U plane address of YUV420P[out]
358  *
359  * @param v_dst
360  *   V plane address of YUV420P[out]
361  *
362  * @param rgb_src
363  *   Address of RGBA8888[in]
364  *
365  * @param width
366  *   Width of RGBA8888[in]
367  *
368  * @param height
369  *   Height of RGBA8888[in]
370  */
371 void csc_RGBA8888_to_YUV420P(
372     unsigned char *y_dst,
373     unsigned char *u_dst,
374     unsigned char *v_dst,
375     unsigned char *rgb_src,
376     unsigned int width,
377     unsigned int height);
378 
379 /*
380  * C code or Neon
381  * Converts RGBA8888 to YUV420SP
382  *
383  * @param y_dst
384  *   Y plane address of YUV420SP[out]
385  *
386  * @param uv_dst
387  *   UV plane address of YUV420SP[out]
388  *
389  * @param rgb_src
390  *   Address of RGBA8888[in]
391  *
392  * @param width
393  *   Width of RGBA8888[in]
394  *
395  * @param height
396  *   Height of RGBA8888[in]
397  */
398 void csc_RGBA8888_to_YUV420SP(
399     unsigned char *y_dst,
400     unsigned char *uv_dst,
401     unsigned char *rgb_src,
402     unsigned int width,
403     unsigned int height);
404 
405 #endif /*COLOR_SPACE_CONVERTOR_H_*/
406