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 SEC_OMX specific define. It support MFC 6.x tiled. 21 * NV12T(tiled) layout: 22 * Each element is not pixel. It is 64x32 pixel block. 23 * uv pixel block is interleaved as u v u v u v ... 24 * y1 y2 y7 y8 y9 y10 y15 y16 25 * y3 y4 y5 y6 y11 y12 y13 y14 26 * y17 y18 y23 y24 y25 y26 y31 y32 27 * y19 y20 y21 y22 y27 y28 y29 y30 28 * uv1 uv2 uv7 uv8 uv9 uv10 uv15 uv16 29 * uv3 uv4 uv5 uv6 uv11 uv12 uv13 uv14 30 * YUV420Planar(linear) layout: 31 * Each element is not pixel. It is 64x32 pixel block. 32 * y1 y2 y3 y4 y5 y6 y7 y8 33 * y9 y10 y11 y12 y13 y14 y15 y16 34 * y17 y18 y19 y20 y21 y22 y23 y24 35 * y25 y26 y27 y28 y29 y30 y31 y32 36 * u1 u2 u3 u4 u5 u6 u7 u8 37 * v1 v2 v3 v4 v5 v6 v7 v8 38 * YUV420Semiplanar(linear) layout: 39 * Each element is not pixel. It is 64x32 pixel block. 40 * uv pixel block is interleaved as u v u v u v ... 41 * y1 y2 y3 y4 y5 y6 y7 y8 42 * y9 y10 y11 y12 y13 y14 y15 y16 43 * y17 y18 y19 y20 y21 y22 y23 y24 44 * y25 y26 y27 y28 y29 y30 y31 y32 45 * uv1 uv2 uv3 uv4 uv5 uv6 uv7 uv8 46 * uv9 uv10 uv11 uv12 uv13 uv14 uv15 uv16 47 * @author ShinWon Lee (shinwon.lee (at) samsung.com) 48 * @version 1.0 49 * @history 50 * 2012.02.01 : Create 51 */ 52 53 #ifndef SW_CONVERTOR_H_ 54 #define SW_CONVERTOR_H_ 55 56 /*--------------------------------------------------------------------------------*/ 57 /* Format Conversion API */ 58 /*--------------------------------------------------------------------------------*/ 59 /* C Code */ 60 /* 61 * De-interleaves src to dest1, dest2 62 * 63 * @param dest1 64 * Address of de-interleaved data[out] 65 * 66 * @param dest2 67 * Address of de-interleaved data[out] 68 * 69 * @param src 70 * Address of interleaved data[in] 71 * 72 * @param src_size 73 * Size of interleaved data[in] 74 */ 75 void csc_deinterleave_memcpy( 76 unsigned char *dest1, 77 unsigned char *dest2, 78 unsigned char *src, 79 unsigned int src_size); 80 81 /* 82 * Interleaves src1, src2 to dest 83 * 84 * @param dest 85 * Address of interleaved data[out] 86 * 87 * @param src1 88 * Address of de-interleaved data[in] 89 * 90 * @param src2 91 * Address of de-interleaved data[in] 92 * 93 * @param src_size 94 * Size of de-interleaved data[in] 95 */ 96 void csc_interleave_memcpy( 97 unsigned char *dest, 98 unsigned char *src1, 99 unsigned char *src2, 100 unsigned int src_size); 101 102 /* 103 * Converts tiled data to linear 104 * It supports mfc 6.x tiled 105 * 1. y of nv12t to y of yuv420p 106 * 2. y of nv12t to y of yuv420s 107 * 108 * @param dst 109 * y address of yuv420[out] 110 * 111 * @param src 112 * y address of nv12t[in] 113 * 114 * @param yuv420_width 115 * real width of yuv420[in] 116 * it should be even 117 * 118 * @param yuv420_height 119 * real height of yuv420[in] 120 * it should be even. 121 * 122 */ 123 void csc_tiled_to_linear_y( 124 unsigned char *y_dst, 125 unsigned char *y_src, 126 unsigned int width, 127 unsigned int height); 128 129 /* 130 * Converts tiled data to linear 131 * It supports mfc 6.x tiled 132 * 1. uv of nv12t to y of yuv420s 133 * 134 * @param dst 135 * uv address of yuv420s[out] 136 * 137 * @param src 138 * uv address of nv12t[in] 139 * 140 * @param yuv420_width 141 * real width of yuv420s[in] 142 * 143 * @param yuv420_height 144 * real height of yuv420s[in] 145 * 146 */ 147 void csc_tiled_to_linear_uv( 148 unsigned char *uv_dst, 149 unsigned char *uv_src, 150 unsigned int width, 151 unsigned int height); 152 153 /* 154 * Converts tiled data to linear 155 * It supports mfc 6.x tiled 156 * 1. uv of nt12t to uv of yuv420p 157 * 158 * @param u_dst 159 * u address of yuv420p[out] 160 * 161 * @param v_dst 162 * v address of yuv420p[out] 163 * 164 * @param uv_src 165 * uv address of nt12t[in] 166 * 167 * @param yuv420_width 168 * real width of yuv420p[in] 169 * 170 * @param yuv420_height 171 * real height of yuv420p[in] 172 */ 173 void csc_tiled_to_linear_uv_deinterleave( 174 unsigned char *u_dst, 175 unsigned char *v_dst, 176 unsigned char *uv_src, 177 unsigned int width, 178 unsigned int height); 179 180 /* 181 * Converts linear data to tiled 182 * It supports mfc 6.x tiled 183 * 1. y of yuv420 to y of nv12t 184 * 185 * @param dst 186 * y address of nv12t[out] 187 * 188 * @param src 189 * y address of yuv420[in] 190 * 191 * @param yuv420_width 192 * real width of yuv420[in] 193 * it should be even 194 * 195 * @param yuv420_height 196 * real height of yuv420[in] 197 * it should be even. 198 * 199 */ 200 void csc_linear_to_tiled_y( 201 unsigned char *y_dst, 202 unsigned char *y_src, 203 unsigned int width, 204 unsigned int height); 205 206 /* 207 * Converts and interleaves linear data to tiled 208 * It supports mfc 6.x tiled 209 * 1. uv of nv12t to uv of yuv420 210 * 211 * @param dst 212 * uv address of nv12t[out] 213 * 214 * @param src 215 * u address of yuv420[in] 216 * 217 * @param src 218 * v address of yuv420[in] 219 * 220 * @param yuv420_width 221 * real width of yuv420[in] 222 * 223 * @param yuv420_height 224 * real height of yuv420[in] 225 * 226 */ 227 void csc_linear_to_tiled_uv( 228 unsigned char *uv_dst, 229 unsigned char *u_src, 230 unsigned char *v_src, 231 unsigned int width, 232 unsigned int height); 233 234 /* 235 * Converts RGB565 to YUV420P 236 * 237 * @param y_dst 238 * Y plane address of YUV420P[out] 239 * 240 * @param u_dst 241 * U plane address of YUV420P[out] 242 * 243 * @param v_dst 244 * V plane address of YUV420P[out] 245 * 246 * @param rgb_src 247 * Address of RGB565[in] 248 * 249 * @param width 250 * Width of RGB565[in] 251 * 252 * @param height 253 * Height of RGB565[in] 254 */ 255 void csc_RGB565_to_YUV420P( 256 unsigned char *y_dst, 257 unsigned char *u_dst, 258 unsigned char *v_dst, 259 unsigned char *rgb_src, 260 int width, 261 int height); 262 263 /* 264 * Converts RGB565 to YUV420S 265 * 266 * @param y_dst 267 * Y plane address of YUV420S[out] 268 * 269 * @param uv_dst 270 * UV plane address of YUV420S[out] 271 * 272 * @param rgb_src 273 * Address of RGB565[in] 274 * 275 * @param width 276 * Width of RGB565[in] 277 * 278 * @param height 279 * Height of RGB565[in] 280 */ 281 void csc_RGB565_to_YUV420SP( 282 unsigned char *y_dst, 283 unsigned char *uv_dst, 284 unsigned char *rgb_src, 285 int width, 286 int height); 287 288 /* 289 * Converts ARGB8888 to YUV420P 290 * 291 * @param y_dst 292 * Y plane address of YUV420P[out] 293 * 294 * @param u_dst 295 * U plane address of YUV420P[out] 296 * 297 * @param v_dst 298 * V plane address of YUV420P[out] 299 * 300 * @param rgb_src 301 * Address of ARGB8888[in] 302 * 303 * @param width 304 * Width of ARGB8888[in] 305 * 306 * @param height 307 * Height of ARGB8888[in] 308 */ 309 void csc_ARGB8888_to_YUV420P( 310 unsigned char *y_dst, 311 unsigned char *u_dst, 312 unsigned char *v_dst, 313 unsigned char *rgb_src, 314 unsigned int width, 315 unsigned int height); 316 317 /* 318 * Converts ARGB8888 to YUV420S 319 * 320 * @param y_dst 321 * Y plane address of YUV420S[out] 322 * 323 * @param uv_dst 324 * UV plane address of YUV420S[out] 325 * 326 * @param rgb_src 327 * Address of ARGB8888[in] 328 * 329 * @param width 330 * Width of ARGB8888[in] 331 * 332 * @param height 333 * Height of ARGB8888[in] 334 */ 335 void csc_ARGB8888_to_YUV420SP( 336 unsigned char *y_dst, 337 unsigned char *uv_dst, 338 unsigned char *rgb_src, 339 unsigned int width, 340 unsigned int height); 341 342 /* 343 * De-interleaves src to dest1, dest2 344 * 345 * @param dest1 346 * Address of de-interleaved data[out] 347 * 348 * @param dest2 349 * Address of de-interleaved data[out] 350 * 351 * @param src 352 * Address of interleaved data[in] 353 * 354 * @param src_size 355 * Size of interleaved data[in] 356 */ 357 void csc_deinterleave_memcpy_neon( 358 unsigned char *dest1, 359 unsigned char *dest2, 360 unsigned char *src, 361 unsigned int src_size); 362 363 /* 364 * Interleaves src1, src2 to dest 365 * 366 * @param dest 367 * Address of interleaved data[out] 368 * 369 * @param src1 370 * Address of de-interleaved data[in] 371 * 372 * @param src2 373 * Address of de-interleaved data[in] 374 * 375 * @param src_size 376 * Size of de-interleaved data[in] 377 */ 378 void csc_interleave_memcpy_neon( 379 unsigned char *dest, 380 unsigned char *src1, 381 unsigned char *src2, 382 unsigned int src_size); 383 384 /* 385 * Converts tiled data to linear for mfc 6.x 386 * 1. Y of NV12T to Y of YUV420P 387 * 2. Y of NV12T to Y of YUV420S 388 * 389 * @param dst 390 * Y address of YUV420[out] 391 * 392 * @param src 393 * Y address of NV12T[in] 394 * 395 * @param yuv420_width 396 * real width of YUV420[in] 397 * 398 * @param yuv420_height 399 * Y: real height of YUV420[in] 400 * 401 */ 402 void csc_tiled_to_linear_y_neon( 403 unsigned char *y_dst, 404 unsigned char *y_src, 405 unsigned int width, 406 unsigned int height); 407 408 /* 409 * Converts tiled data to linear for mfc 6.x 410 * 1. UV of NV12T to Y of YUV420S 411 * 412 * @param u_dst 413 * UV plane address of YUV420P[out] 414 * 415 * @param nv12t_src 416 * Y or UV plane address of NV12T[in] 417 * 418 * @param yuv420_width 419 * real width of YUV420[in] 420 * 421 * @param yuv420_height 422 * (real height)/2 of YUV420[in] 423 */ 424 void csc_tiled_to_linear_uv_neon( 425 unsigned char *uv_dst, 426 unsigned char *uv_src, 427 unsigned int width, 428 unsigned int height); 429 430 /* 431 * Converts tiled data to linear for mfc 6.x 432 * Deinterleave src to u_dst, v_dst 433 * 1. UV of NV12T to Y of YUV420P 434 * 435 * @param u_dst 436 * U plane address of YUV420P[out] 437 * 438 * @param v_dst 439 * V plane address of YUV420P[out] 440 * 441 * @param nv12t_src 442 * Y or UV plane address of NV12T[in] 443 * 444 * @param yuv420_width 445 * real width of YUV420[in] 446 * 447 * @param yuv420_height 448 * (real height)/2 of YUV420[in] 449 */ 450 void csc_tiled_to_linear_uv_deinterleave_neon( 451 unsigned char *u_dst, 452 unsigned char *v_dst, 453 unsigned char *uv_src, 454 unsigned int width, 455 unsigned int height); 456 457 /* 458 * Converts linear data to tiled 459 * It supports mfc 6.x tiled 460 * 1. y of yuv420 to y of nv12t 461 * 462 * @param dst 463 * y address of nv12t[out] 464 * 465 * @param src 466 * y address of yuv420[in] 467 * 468 * @param yuv420_width 469 * real width of yuv420[in] 470 * it should be even 471 * 472 * @param yuv420_height 473 * real height of yuv420[in] 474 * it should be even. 475 * 476 */ 477 void csc_linear_to_tiled_y_neon( 478 unsigned char *y_dst, 479 unsigned char *y_src, 480 unsigned int width, 481 unsigned int height); 482 483 /* 484 * Converts and interleave linear data to tiled 485 * It supports mfc 6.x tiled 486 * 1. uv of nv12t to uv of yuv420 487 * 488 * @param dst 489 * uv address of yuv420[out] 490 * 491 * @param src 492 * uv address of nv12t[in] 493 * 494 * @param yuv420_width 495 * real width of yuv420[in] 496 * 497 * @param yuv420_height 498 * real height of yuv420[in] 499 * 500 */ 501 void csc_linear_to_tiled_uv_neon( 502 unsigned char *uv_dst, 503 unsigned char *uv_src, 504 unsigned int width, 505 unsigned int height); 506 507 void csc_ARGB8888_to_YUV420SP_NEON( 508 unsigned char *y_dst, 509 unsigned char *uv_dst, 510 unsigned char *rgb_src, 511 unsigned int width, 512 unsigned int height); 513 514 #endif /*COLOR_SPACE_CONVERTOR_H_*/ 515