3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * @brief SEC_OMX specific define
23 * @author ShinWon Lee (shinwon.lee@samsung.com)
35 #include "swconverter.h"
38 * Get tiled address of position(x,y)
47 * x position of tield[in]
50 * y position of tield[in]
53 * address of tiled data
55 static int tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)
57 int pixel_x_m1, pixel_y_m1;
59 int linear_addr0, linear_addr1, bank_addr ;
63 pixel_x_m1 = x_size -1;
64 pixel_y_m1 = y_size -1;
66 roundup_x = ((pixel_x_m1 >> 7) + 1);
70 if ((y_size <= y_pos+32) && ( y_pos < y_size) &&
71 (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {
72 linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));
73 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));
75 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
76 bank_addr = ((x_addr >> 4) & 0x1);
78 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
80 linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));
81 linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));
83 if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
84 bank_addr = ((x_addr >> 4) & 0x1);
86 bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
89 linear_addr0 = linear_addr0 << 2;
90 trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;
96 * De-interleaves src to dest1, dest2
99 * Address of de-interleaved data[out]
102 * Address of de-interleaved data[out]
105 * Address of interleaved data[in]
108 * Size of interleaved data[in]
110 void csc_deinterleave_memcpy(
111 unsigned char *dest1,
112 unsigned char *dest2,
114 unsigned int src_size)
117 for(i=0; i<src_size/2; i++) {
119 dest2[i] = src[i*2+1];
124 * Interleaves src1, src2 to dest
127 * Address of interleaved data[out]
130 * Address of de-interleaved data[in]
133 * Address of de-interleaved data[in]
136 * Size of de-interleaved data[in]
138 void csc_interleave_memcpy(
142 unsigned int src_size)
145 for(i=0; i<src_size; i++) {
146 dest[i * 2] = src1[i];
147 dest[i * 2 + 1] = src2[i];
152 * Converts tiled data to linear
153 * Crops left, top, right, buttom
154 * 1. Y of NV12T to Y of YUV420P
155 * 2. Y of NV12T to Y of YUV420S
156 * 3. UV of NV12T to UV of YUV420S
159 * Y or UV plane address of YUV420[out]
162 * Y or UV plane address of NV12T[in]
164 * @param yuv420_width
165 * Width of YUV420[in]
167 * @param yuv420_height
168 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
180 * Crop size of buttom
182 static void csc_tiled_to_linear_crop(
183 unsigned char *yuv420_dest,
184 unsigned char *nv12t_src,
185 unsigned int yuv420_width,
186 unsigned int yuv420_height,
193 unsigned int tiled_offset = 0, tiled_offset1 = 0;
194 unsigned int linear_offset = 0;
195 unsigned int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
197 temp3 = yuv420_width-right;
199 /* real width is greater than or equal 256 */
201 for (i=top; i<yuv420_height-buttom; i=i+1) {
207 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
208 tiled_offset = temp4-1;
209 temp1 = ((yuv420_width+127)>>7)<<7;
210 tiled_offset = tiled_offset*(temp1>>6);
211 tiled_offset = tiled_offset+temp3;
212 tiled_offset = tiled_offset+2;
213 temp1 = (temp3>>2)<<2;
214 tiled_offset = tiled_offset+temp1;
215 tiled_offset = tiled_offset<<11;
216 tiled_offset1 = tiled_offset+2048*2;
219 temp2 = ((yuv420_height+31)>>5)<<5;
221 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
223 temp1 = (temp1>>2)<<2;
224 tiled_offset = temp3+temp1;
225 temp1 = ((yuv420_width+127)>>7)<<7;
226 tiled_offset = tiled_offset+temp4*(temp1>>6);
227 tiled_offset = tiled_offset<<11;
228 tiled_offset1 = tiled_offset+2048*6;
231 /* even2 fomula: x+x_block_num*y */
232 temp1 = ((yuv420_width+127)>>7)<<7;
233 tiled_offset = temp4*(temp1>>6);
234 tiled_offset = tiled_offset+temp3;
235 tiled_offset = tiled_offset<<11;
236 tiled_offset1 = tiled_offset+2048*2;
242 tiled_offset = tiled_offset+64*(temp1);
243 tiled_offset1 = tiled_offset1+64*(temp1);
244 temp2 = yuv420_width-left-right;
245 linear_offset = temp2*(i-top);
246 temp3 = ((j+256)>>8)<<8;
250 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
251 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
252 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
253 memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
254 linear_offset = linear_offset+256-temp1;
255 } else if (temp3 > 128) {
256 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);
257 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);
258 memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);
259 linear_offset = linear_offset+192-temp1;
260 } else if (temp3 > 64) {
261 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);
262 memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);
263 linear_offset = linear_offset+128-temp1;
264 } else if (temp3 > 0) {
265 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);
266 linear_offset = linear_offset+64-temp1;
269 tiled_offset = tiled_offset+temp4*2048;
272 temp2 = yuv420_width-right-256;
273 for (; j<=temp2; j=j+256) {
274 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
275 tiled_offset1 = tiled_offset1+temp4*2048;
276 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
277 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
278 tiled_offset = tiled_offset+temp4*2048;
279 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);
280 linear_offset = linear_offset+256;
283 tiled_offset1 = tiled_offset1+temp4*2048;
284 temp2 = yuv420_width-right-j;
286 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
287 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
288 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
289 memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);
290 } else if (temp2 > 128) {
291 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
292 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
293 memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, temp2-128);
294 } else if (temp2 > 64) {
295 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
296 memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);
298 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
301 } else if (temp1 >= 64) {
302 for (i=top; i<(yuv420_height-buttom); i=i+1) {
304 tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
305 temp2 = ((j+64)>>6)<<6;
307 linear_offset = temp1*(i-top);
309 tiled_offset = tiled_offset+temp4;
310 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
311 linear_offset = linear_offset+temp2;
313 if ((j+64) <= temp3) {
314 tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
315 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
316 linear_offset = linear_offset+64;
319 if ((j+64) <= temp3) {
320 tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
321 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
322 linear_offset = linear_offset+64;
326 tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
328 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
332 for (i=top; i<(yuv420_height-buttom); i=i+1) {
333 linear_offset = temp1*(i-top);
334 for (j=left; j<(yuv420_width-right); j=j+2) {
335 tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
337 tiled_offset = tiled_offset+temp4;
338 memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);
339 linear_offset = linear_offset+2;
346 * Converts and Deinterleaves tiled data to linear
347 * Crops left, top, right, buttom
348 * 1. UV of NV12T to UV of YUV420P
350 * @param yuv420_u_dest
351 * U plane address of YUV420P[out]
353 * @param yuv420_v_dest
354 * V plane address of YUV420P[out]
357 * UV plane address of NV12T[in]
359 * @param yuv420_width
360 * Width of YUV420[in]
362 * @param yuv420_uv_height
363 * Height/2 of YUV420[in]
375 * Crop size of buttom
377 static void csc_tiled_to_linear_deinterleave_crop(
378 unsigned char *yuv420_u_dest,
379 unsigned char *yuv420_v_dest,
380 unsigned char *nv12t_uv_src,
381 unsigned int yuv420_width,
382 unsigned int yuv420_uv_height,
389 unsigned int tiled_offset = 0, tiled_offset1 = 0;
390 unsigned int linear_offset = 0;
391 unsigned int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
393 temp3 = yuv420_width-right;
395 /* real width is greater than or equal 256 */
397 for (i=top; i<yuv420_uv_height-buttom; i=i+1) {
403 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
404 tiled_offset = temp4-1;
405 temp1 = ((yuv420_width+127)>>7)<<7;
406 tiled_offset = tiled_offset*(temp1>>6);
407 tiled_offset = tiled_offset+temp3;
408 tiled_offset = tiled_offset+2;
409 temp1 = (temp3>>2)<<2;
410 tiled_offset = tiled_offset+temp1;
411 tiled_offset = tiled_offset<<11;
412 tiled_offset1 = tiled_offset+2048*2;
415 temp2 = ((yuv420_uv_height+31)>>5)<<5;
417 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
419 temp1 = (temp1>>2)<<2;
420 tiled_offset = temp3+temp1;
421 temp1 = ((yuv420_width+127)>>7)<<7;
422 tiled_offset = tiled_offset+temp4*(temp1>>6);
423 tiled_offset = tiled_offset<<11;
424 tiled_offset1 = tiled_offset+2048*6;
427 /* even2 fomula: x+x_block_num*y */
428 temp1 = ((yuv420_width+127)>>7)<<7;
429 tiled_offset = temp4*(temp1>>6);
430 tiled_offset = tiled_offset+temp3;
431 tiled_offset = tiled_offset<<11;
432 tiled_offset1 = tiled_offset+2048*2;
438 tiled_offset = tiled_offset+64*(temp1);
439 tiled_offset1 = tiled_offset1+64*(temp1);
440 temp2 = yuv420_width-left-right;
441 linear_offset = temp2*(i-top)/2;
442 temp3 = ((j+256)>>8)<<8;
446 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset, yuv420_v_dest+linear_offset, nv12t_uv_src+tiled_offset+temp1, 64-temp1);
447 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
448 yuv420_v_dest+linear_offset+(32-temp1/2),
449 nv12t_uv_src+tiled_offset+2048, 64);
450 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(64-temp1/2),
451 yuv420_v_dest+linear_offset+(64-temp1/2),
452 nv12t_uv_src+tiled_offset1, 64);
453 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(96-temp1/2),
454 yuv420_v_dest+linear_offset+(96-temp1/2),
455 nv12t_uv_src+tiled_offset1+2048, 64);
456 linear_offset = linear_offset+128-temp1/2;
457 } else if (temp3 > 128) {
458 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
459 yuv420_v_dest+linear_offset,
460 nv12t_uv_src+tiled_offset+2048+temp1, 64-temp1);
461 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
462 yuv420_v_dest+linear_offset+(32-temp1/2),
463 nv12t_uv_src+tiled_offset1, 64);
464 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(64-temp1/2),
465 yuv420_v_dest+linear_offset+(64-temp1/2),
466 nv12t_uv_src+tiled_offset1+2048, 64);
467 linear_offset = linear_offset+96-temp1/2;
468 } else if (temp3 > 64) {
469 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
470 yuv420_v_dest+linear_offset,
471 nv12t_uv_src+tiled_offset1+temp1, 64-temp1);
472 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
473 yuv420_v_dest+linear_offset+(32-temp1/2),
474 nv12t_uv_src+tiled_offset1+2048, 64);
475 linear_offset = linear_offset+64-temp1/2;
476 } else if (temp3 > 0) {
477 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
478 yuv420_v_dest+linear_offset,
479 nv12t_uv_src+tiled_offset1+2048+temp1, 64-temp1);
480 linear_offset = linear_offset+32-temp1/2;
483 tiled_offset = tiled_offset+temp4*2048;
486 temp2 = yuv420_width-right-256;
487 for (; j<=temp2; j=j+256) {
488 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
489 yuv420_v_dest+linear_offset,
490 nv12t_uv_src+tiled_offset, 64);
491 tiled_offset1 = tiled_offset1+temp4*2048;
492 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
493 yuv420_v_dest+linear_offset+32,
494 nv12t_uv_src+tiled_offset+2048, 64);
495 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
496 yuv420_v_dest+linear_offset+64,
497 nv12t_uv_src+tiled_offset1, 64);
498 tiled_offset = tiled_offset+temp4*2048;
499 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+96,
500 yuv420_v_dest+linear_offset+96,
501 nv12t_uv_src+tiled_offset1+2048, 64);
502 linear_offset = linear_offset+128;
505 tiled_offset1 = tiled_offset1+temp4*2048;
506 temp2 = yuv420_width-right-j;
508 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
509 yuv420_v_dest+linear_offset,
510 nv12t_uv_src+tiled_offset, 64);
511 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
512 yuv420_v_dest+linear_offset+32,
513 nv12t_uv_src+tiled_offset+2048, 64);
514 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
515 yuv420_v_dest+linear_offset+64,
516 nv12t_uv_src+tiled_offset1, 64);
517 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+96,
518 yuv420_v_dest+linear_offset+96,
519 nv12t_uv_src+tiled_offset1+2048, temp2-192);
520 } else if (temp2 > 128) {
521 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
522 yuv420_v_dest+linear_offset,
523 nv12t_uv_src+tiled_offset, 64);
524 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
525 yuv420_v_dest+linear_offset+32,
526 nv12t_uv_src+tiled_offset+2048, 64);
527 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
528 yuv420_v_dest+linear_offset+64,
529 nv12t_uv_src+tiled_offset1, temp2-128);
530 } else if (temp2 > 64) {
531 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
532 yuv420_v_dest+linear_offset,
533 nv12t_uv_src+tiled_offset, 64);
534 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
535 yuv420_v_dest+linear_offset+32,
536 nv12t_uv_src+tiled_offset+2048, temp2-64);
538 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
539 yuv420_v_dest+linear_offset,
540 nv12t_uv_src+tiled_offset, temp2);
543 } else if (temp1 >= 64) {
544 for (i=top; i<(yuv420_uv_height-buttom); i=i+1) {
546 tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
547 temp2 = ((j+64)>>6)<<6;
549 temp3 = yuv420_width-right;
551 linear_offset = temp4*(i-top)/2;
553 tiled_offset = tiled_offset+temp4;
554 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
555 yuv420_v_dest+linear_offset,
556 nv12t_uv_src+tiled_offset, temp2);
557 linear_offset = linear_offset+temp2/2;
559 if ((j+64) <= temp3) {
560 tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
561 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
562 yuv420_v_dest+linear_offset,
563 nv12t_uv_src+tiled_offset, 64);
564 linear_offset = linear_offset+32;
567 if ((j+64) <= temp3) {
568 tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
569 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
570 yuv420_v_dest+linear_offset,
571 nv12t_uv_src+tiled_offset, 64);
572 linear_offset = linear_offset+32;
576 tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
578 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
579 yuv420_v_dest+linear_offset,
580 nv12t_uv_src+tiled_offset, temp1);
584 for (i=top; i<(yuv420_uv_height-buttom); i=i+1) {
585 temp3 = yuv420_width-right;
587 linear_offset = temp4*(i-top)/2;
588 for (j=left; j<(yuv420_width-right); j=j+2) {
589 tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
591 tiled_offset = tiled_offset+temp3;
592 csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
593 yuv420_v_dest+linear_offset,
594 nv12t_uv_src+tiled_offset, 2);
595 linear_offset = linear_offset+1;
602 * Converts linear data to tiled
603 * Crops left, top, right, buttom
604 * 1. Y of YUV420P to Y of NV12T
605 * 2. Y of YUV420S to Y of NV12T
606 * 3. UV of YUV420S to UV of NV12T
609 * Y or UV plane address of NV12T[out]
612 * Y or UV plane address of YUV420P(S)[in]
614 * @param yuv420_width
615 * Width of YUV420[in]
617 * @param yuv420_height
618 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
630 * Crop size of buttom
632 static void csc_linear_to_tiled_crop(
633 unsigned char *nv12t_dest,
634 unsigned char *yuv420_src,
635 unsigned int yuv420_width,
636 unsigned int yuv420_height,
643 unsigned int tiled_x_index = 0, tiled_y_index = 0;
644 unsigned int aligned_x_size = 0, aligned_y_size = 0;
645 unsigned int tiled_offset = 0;
646 unsigned int temp1 = 0, temp2 = 0;
648 aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5;
649 aligned_x_size = ((yuv420_width-left-right)>>6)<<6;
651 for (i=0; i<aligned_y_size; i=i+32) {
652 for (j=0; j<aligned_x_size; j=j+64) {
654 tiled_x_index = j>>6;
655 tiled_y_index = i>>5;
656 if (tiled_y_index & 0x1) {
657 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
658 tiled_offset = tiled_y_index-1;
659 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
660 tiled_offset = tiled_offset*(temp1>>6);
661 tiled_offset = tiled_offset+tiled_x_index;
662 tiled_offset = tiled_offset+2;
663 temp1 = (tiled_x_index>>2)<<2;
664 tiled_offset = tiled_offset+temp1;
665 tiled_offset = tiled_offset<<11;
667 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
669 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
670 temp1 = tiled_x_index+2;
671 temp1 = (temp1>>2)<<2;
672 tiled_offset = tiled_x_index+temp1;
673 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
674 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
675 tiled_offset = tiled_offset<<11;
677 /* even2 fomula: x+x_block_num*y */
678 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
679 tiled_offset = tiled_y_index*(temp1>>6);
680 tiled_offset = tiled_offset+tiled_x_index;
681 tiled_offset = tiled_offset<<11;
685 memcpy(nv12t_dest+tiled_offset, yuv420_src+left+j+yuv420_width*(i+top), 64);
686 memcpy(nv12t_dest+tiled_offset+64*1, yuv420_src+left+j+yuv420_width*(i+top+1), 64);
687 memcpy(nv12t_dest+tiled_offset+64*2, yuv420_src+left+j+yuv420_width*(i+top+2), 64);
688 memcpy(nv12t_dest+tiled_offset+64*3, yuv420_src+left+j+yuv420_width*(i+top+3), 64);
689 memcpy(nv12t_dest+tiled_offset+64*4, yuv420_src+left+j+yuv420_width*(i+top+4), 64);
690 memcpy(nv12t_dest+tiled_offset+64*5, yuv420_src+left+j+yuv420_width*(i+top+5), 64);
691 memcpy(nv12t_dest+tiled_offset+64*6, yuv420_src+left+j+yuv420_width*(i+top+6), 64);
692 memcpy(nv12t_dest+tiled_offset+64*7, yuv420_src+left+j+yuv420_width*(i+top+7), 64);
693 memcpy(nv12t_dest+tiled_offset+64*8, yuv420_src+left+j+yuv420_width*(i+top+8), 64);
694 memcpy(nv12t_dest+tiled_offset+64*9, yuv420_src+left+j+yuv420_width*(i+top+9), 64);
695 memcpy(nv12t_dest+tiled_offset+64*10, yuv420_src+left+j+yuv420_width*(i+top+10), 64);
696 memcpy(nv12t_dest+tiled_offset+64*11, yuv420_src+left+j+yuv420_width*(i+top+11), 64);
697 memcpy(nv12t_dest+tiled_offset+64*12, yuv420_src+left+j+yuv420_width*(i+top+12), 64);
698 memcpy(nv12t_dest+tiled_offset+64*13, yuv420_src+left+j+yuv420_width*(i+top+13), 64);
699 memcpy(nv12t_dest+tiled_offset+64*14, yuv420_src+left+j+yuv420_width*(i+top+14), 64);
700 memcpy(nv12t_dest+tiled_offset+64*15, yuv420_src+left+j+yuv420_width*(i+top+15), 64);
701 memcpy(nv12t_dest+tiled_offset+64*16, yuv420_src+left+j+yuv420_width*(i+top+16), 64);
702 memcpy(nv12t_dest+tiled_offset+64*17, yuv420_src+left+j+yuv420_width*(i+top+17), 64);
703 memcpy(nv12t_dest+tiled_offset+64*18, yuv420_src+left+j+yuv420_width*(i+top+18), 64);
704 memcpy(nv12t_dest+tiled_offset+64*19, yuv420_src+left+j+yuv420_width*(i+top+19), 64);
705 memcpy(nv12t_dest+tiled_offset+64*20, yuv420_src+left+j+yuv420_width*(i+top+20), 64);
706 memcpy(nv12t_dest+tiled_offset+64*21, yuv420_src+left+j+yuv420_width*(i+top+21), 64);
707 memcpy(nv12t_dest+tiled_offset+64*22, yuv420_src+left+j+yuv420_width*(i+top+22), 64);
708 memcpy(nv12t_dest+tiled_offset+64*23, yuv420_src+left+j+yuv420_width*(i+top+23), 64);
709 memcpy(nv12t_dest+tiled_offset+64*24, yuv420_src+left+j+yuv420_width*(i+top+24), 64);
710 memcpy(nv12t_dest+tiled_offset+64*25, yuv420_src+left+j+yuv420_width*(i+top+25), 64);
711 memcpy(nv12t_dest+tiled_offset+64*26, yuv420_src+left+j+yuv420_width*(i+top+26), 64);
712 memcpy(nv12t_dest+tiled_offset+64*27, yuv420_src+left+j+yuv420_width*(i+top+27), 64);
713 memcpy(nv12t_dest+tiled_offset+64*28, yuv420_src+left+j+yuv420_width*(i+top+28), 64);
714 memcpy(nv12t_dest+tiled_offset+64*29, yuv420_src+left+j+yuv420_width*(i+top+29), 64);
715 memcpy(nv12t_dest+tiled_offset+64*30, yuv420_src+left+j+yuv420_width*(i+top+30), 64);
716 memcpy(nv12t_dest+tiled_offset+64*31, yuv420_src+left+j+yuv420_width*(i+top+31), 64);
720 for (i=aligned_y_size; i<(yuv420_height-top-buttom); i=i+2) {
721 for (j=0; j<aligned_x_size; j=j+64) {
723 tiled_x_index = j>>6;
724 tiled_y_index = i>>5;
725 if (tiled_y_index & 0x1) {
726 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
727 tiled_offset = tiled_y_index-1;
728 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
729 tiled_offset = tiled_offset*(temp1>>6);
730 tiled_offset = tiled_offset+tiled_x_index;
731 tiled_offset = tiled_offset+2;
732 temp1 = (tiled_x_index>>2)<<2;
733 tiled_offset = tiled_offset+temp1;
734 tiled_offset = tiled_offset<<11;
736 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
738 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
739 temp1 = tiled_x_index+2;
740 temp1 = (temp1>>2)<<2;
741 tiled_offset = tiled_x_index+temp1;
742 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
743 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
744 tiled_offset = tiled_offset<<11;
746 /* even2 fomula: x+x_block_num*y */
747 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
748 tiled_offset = tiled_y_index*(temp1>>6);
749 tiled_offset = tiled_offset+tiled_x_index;
750 tiled_offset = tiled_offset<<11;
755 memcpy(nv12t_dest+tiled_offset+64*(temp1), yuv420_src+left+j+yuv420_width*(i+top), 64);
756 memcpy(nv12t_dest+tiled_offset+64*(temp1+1), yuv420_src+left+j+yuv420_width*(i+top+1), 64);
760 for (i=0; i<(yuv420_height-top-buttom); i=i+2) {
761 for (j=aligned_x_size; j<(yuv420_width-left-right); j=j+2) {
763 tiled_x_index = j>>6;
764 tiled_y_index = i>>5;
765 if (tiled_y_index & 0x1) {
766 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
767 tiled_offset = tiled_y_index-1;
768 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
769 tiled_offset = tiled_offset*(temp1>>6);
770 tiled_offset = tiled_offset+tiled_x_index;
771 tiled_offset = tiled_offset+2;
772 temp1 = (tiled_x_index>>2)<<2;
773 tiled_offset = tiled_offset+temp1;
774 tiled_offset = tiled_offset<<11;
776 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
778 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
779 temp1 = tiled_x_index+2;
780 temp1 = (temp1>>2)<<2;
781 tiled_offset = tiled_x_index+temp1;
782 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
783 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
784 tiled_offset = tiled_offset<<11;
786 /* even2 fomula: x+x_block_num*y */
787 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
788 tiled_offset = tiled_y_index*(temp1>>6);
789 tiled_offset = tiled_offset+tiled_x_index;
790 tiled_offset = tiled_offset<<11;
796 memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1), yuv420_src+left+j+yuv420_width*(i+top), 2);
797 memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1+1), yuv420_src+left+j+yuv420_width*(i+top+1), 2);
804 * Converts and Interleaves linear to tiled
805 * Crops left, top, right, buttom
806 * 1. UV of YUV420P to UV of NV12T
808 * @param nv12t_uv_dest
809 * UV plane address of NV12T[out]
811 * @param yuv420p_u_src
812 * U plane address of YUV420P[in]
814 * @param yuv420p_v_src
815 * V plane address of YUV420P[in]
817 * @param yuv420_width
818 * Width of YUV420[in]
820 * @param yuv420_uv_height
821 * Height/2 of YUV420[in]
833 * Crop size of buttom
835 static void csc_linear_to_tiled_interleave_crop(
836 unsigned char *nv12t_uv_dest,
837 unsigned char *yuv420_u_src,
838 unsigned char *yuv420_v_src,
839 unsigned int yuv420_width,
840 unsigned int yuv420_height,
847 unsigned int tiled_x_index = 0, tiled_y_index = 0;
848 unsigned int aligned_x_size = 0, aligned_y_size = 0;
849 unsigned int tiled_offset = 0;
850 unsigned int temp1 = 0, temp2 = 0;
852 aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5;
853 aligned_x_size = ((yuv420_width-left-right)>>6)<<6;
855 for (i=0; i<aligned_y_size; i=i+32) {
856 for (j=0; j<aligned_x_size; j=j+64) {
858 tiled_x_index = j>>6;
859 tiled_y_index = i>>5;
860 if (tiled_y_index & 0x1) {
861 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
862 tiled_offset = tiled_y_index-1;
863 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
864 tiled_offset = tiled_offset*(temp1>>6);
865 tiled_offset = tiled_offset+tiled_x_index;
866 tiled_offset = tiled_offset+2;
867 temp1 = (tiled_x_index>>2)<<2;
868 tiled_offset = tiled_offset+temp1;
869 tiled_offset = tiled_offset<<11;
871 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
873 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
874 temp1 = tiled_x_index+2;
875 temp1 = (temp1>>2)<<2;
876 tiled_offset = tiled_x_index+temp1;
877 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
878 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
879 tiled_offset = tiled_offset<<11;
881 /* even2 fomula: x+x_block_num*y */
882 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
883 tiled_offset = tiled_y_index*(temp1>>6);
884 tiled_offset = tiled_offset+tiled_x_index;
885 tiled_offset = tiled_offset<<11;
889 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset,
890 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
891 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 32);
892 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*1,
893 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+1),
894 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+1), 32);
895 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*2,
896 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+2),
897 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+2), 32);
898 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*3,
899 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+3),
900 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+3), 32);
901 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*4,
902 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+4),
903 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+4), 32);
904 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*5,
905 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+5),
906 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+5), 32);
907 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*6,
908 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+6),
909 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+6), 32);
910 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*7,
911 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+7),
912 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+7), 32);
913 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*8,
914 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+8),
915 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+8), 32);
916 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*9,
917 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+9),
918 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+9), 32);
919 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*10,
920 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+10),
921 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+10), 32);
922 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*11,
923 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+11),
924 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+11), 32);
925 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*12,
926 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+12),
927 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+12), 32);
928 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*13,
929 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+13),
930 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+13), 32);
931 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*14,
932 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+14),
933 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+14), 32);
934 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*15,
935 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+15),
936 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+15), 32);
937 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*16,
938 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+16),
939 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+16), 32);
940 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*17,
941 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+17),
942 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+17), 32);
943 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*18,
944 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+18),
945 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+18), 32);
946 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*19,
947 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+19),
948 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+19), 32);
949 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*20,
950 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+20),
951 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+20), 32);
952 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*21,
953 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+21),
954 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+21), 32);
955 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*22,
956 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+22),
957 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+22), 32);
958 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*23,
959 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+23),
960 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+23), 32);
961 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*24,
962 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+24),
963 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+24), 32);
964 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*25,
965 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+25),
966 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+25), 32);
967 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*26,
968 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+26),
969 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+26), 32);
970 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*27,
971 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+27),
972 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+27), 32);
973 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*28,
974 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+28),
975 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+28), 32);
976 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*29,
977 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+29),
978 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+29), 32);
979 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*30,
980 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+30),
981 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+30), 32);
982 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*31,
983 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+31),
984 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+31), 32);
989 for (i=aligned_y_size; i<(yuv420_height-top-buttom); i=i+1) {
990 for (j=0; j<aligned_x_size; j=j+64) {
992 tiled_x_index = j>>6;
993 tiled_y_index = i>>5;
994 if (tiled_y_index & 0x1) {
995 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
996 tiled_offset = tiled_y_index-1;
997 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
998 tiled_offset = tiled_offset*(temp1>>6);
999 tiled_offset = tiled_offset+tiled_x_index;
1000 tiled_offset = tiled_offset+2;
1001 temp1 = (tiled_x_index>>2)<<2;
1002 tiled_offset = tiled_offset+temp1;
1003 tiled_offset = tiled_offset<<11;
1005 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
1007 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
1008 temp1 = tiled_x_index+2;
1009 temp1 = (temp1>>2)<<2;
1010 tiled_offset = tiled_x_index+temp1;
1011 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
1012 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
1013 tiled_offset = tiled_offset<<11;
1015 /* even2 fomula: x+x_block_num*y */
1016 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
1017 tiled_offset = tiled_y_index*(temp1>>6);
1018 tiled_offset = tiled_offset+tiled_x_index;
1019 tiled_offset = tiled_offset<<11;
1023 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1),
1024 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
1025 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 32);
1029 for (i=0; i<(yuv420_height-top-buttom); i=i+1) {
1030 for (j=aligned_x_size; j<(yuv420_width-left-right); j=j+2) {
1032 tiled_x_index = j>>6;
1033 tiled_y_index = i>>5;
1034 if (tiled_y_index & 0x1) {
1035 /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
1036 tiled_offset = tiled_y_index-1;
1037 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
1038 tiled_offset = tiled_offset*(temp1>>6);
1039 tiled_offset = tiled_offset+tiled_x_index;
1040 tiled_offset = tiled_offset+2;
1041 temp1 = (tiled_x_index>>2)<<2;
1042 tiled_offset = tiled_offset+temp1;
1043 tiled_offset = tiled_offset<<11;
1045 temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
1047 /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
1048 temp1 = tiled_x_index+2;
1049 temp1 = (temp1>>2)<<2;
1050 tiled_offset = tiled_x_index+temp1;
1051 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
1052 tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
1053 tiled_offset = tiled_offset<<11;
1055 /* even2 fomula: x+x_block_num*y */
1056 temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
1057 tiled_offset = tiled_y_index*(temp1>>6);
1058 tiled_offset = tiled_offset+tiled_x_index;
1059 tiled_offset = tiled_offset<<11;
1064 csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1),
1065 yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
1066 yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 1);
1074 * Converts tiled data to linear
1075 * Crops left, top, right, buttom
1076 * 1. Y of NV12T to Y of YUV420P
1077 * 2. Y of NV12T to Y of YUV420S
1078 * 3. UV of NV12T to UV of YUV420S
1080 * @param yuv420_dest
1081 * Y or UV plane address of YUV420[out]
1084 * Y or UV plane address of NV12T[in]
1086 * @param yuv420_width
1087 * Width of YUV420[in]
1089 * @param yuv420_height
1090 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
1099 * Crop size of right
1102 * Crop size of buttom
1104 void csc_tiled_to_linear_crop_neon(
1105 unsigned char *yuv420_dest,
1106 unsigned char *nv12t_src,
1107 unsigned int yuv420_width,
1108 unsigned int yuv420_height,
1112 unsigned int buttom);
1115 * Converts and Deinterleaves tiled data to linear
1116 * Crops left, top, right, buttom
1117 * 1. UV of NV12T to UV of YUV420P
1119 * @param yuv420_u_dest
1120 * U plane address of YUV420P[out]
1122 * @param yuv420_v_dest
1123 * V plane address of YUV420P[out]
1126 * UV plane address of NV12T[in]
1128 * @param yuv420_width
1129 * Width of YUV420[in]
1131 * @param yuv420_uv_height
1132 * Height/2 of YUV420[in]
1141 * Crop size of right
1144 * Crop size of buttom
1146 void csc_tiled_to_linear_deinterleave_crop_neon(
1147 unsigned char *yuv420_u_dest,
1148 unsigned char *yuv420_v_dest,
1149 unsigned char *nv12t_uv_src,
1150 unsigned int yuv420_width,
1151 unsigned int yuv420_uv_height,
1155 unsigned int buttom);
1158 * Converts linear data to tiled
1159 * Crops left, top, right, buttom
1160 * 1. Y of YUV420P to Y of NV12T
1161 * 2. Y of YUV420S to Y of NV12T
1162 * 3. UV of YUV420S to UV of NV12T
1165 * Y or UV plane address of NV12T[out]
1168 * Y or UV plane address of YUV420P(S)[in]
1170 * @param yuv420_width
1171 * Width of YUV420[in]
1173 * @param yuv420_height
1174 * Y: Height of YUV420, UV: Height/2 of YUV420[in]
1183 * Crop size of right
1186 * Crop size of buttom
1188 void csc_linear_to_tiled_crop_neon(
1189 unsigned char *nv12t_dest,
1190 unsigned char *yuv420_src,
1191 unsigned int yuv420_width,
1192 unsigned int yuv420_height,
1196 unsigned int buttom);
1199 * Converts and Interleaves linear to tiled
1200 * Crops left, top, right, buttom
1201 * 1. UV of YUV420P to UV of NV12T
1203 * @param nv12t_uv_dest
1204 * UV plane address of NV12T[out]
1206 * @param yuv420p_u_src
1207 * U plane address of YUV420P[in]
1209 * @param yuv420p_v_src
1210 * V plane address of YUV420P[in]
1212 * @param yuv420_width
1213 * Width of YUV420[in]
1215 * @param yuv420_uv_height
1216 * Height/2 of YUV420[in]
1225 * Crop size of right
1228 * Crop size of buttom
1230 void csc_linear_to_tiled_interleave_crop_neon(
1231 unsigned char *nv12t_uv_dest,
1232 unsigned char *yuv420_u_src,
1233 unsigned char *yuv420_v_src,
1234 unsigned int yuv420_width,
1235 unsigned int yuv420_height,
1239 unsigned int buttom);
1242 * Converts tiled data to linear.
1243 * 1. y of nv12t to y of yuv420p
1244 * 2. y of nv12t to y of yuv420s
1247 * y address of yuv420[out]
1250 * y address of nv12t[in]
1252 * @param yuv420_width
1253 * real width of yuv420[in]
1256 * @param yuv420_height
1257 * real height of yuv420[in]
1258 * it should be even.
1261 void csc_tiled_to_linear_y(
1262 unsigned char *y_dst,
1263 unsigned char *y_src,
1265 unsigned int height)
1267 csc_tiled_to_linear_crop(y_dst, y_src, width, height, 0, 0, 0, 0);
1271 * Converts tiled data to linear
1272 * 1. uv of nv12t to y of yuv420s
1275 * uv address of yuv420s[out]
1278 * uv address of nv12t[in]
1280 * @param yuv420_width
1281 * real width of yuv420s[in]
1283 * @param yuv420_height
1284 * real height of yuv420s[in]
1287 void csc_tiled_to_linear_uv(
1288 unsigned char *uv_dst,
1289 unsigned char *uv_src,
1291 unsigned int height)
1293 csc_tiled_to_linear_crop(uv_dst, uv_src, width, height, 0, 0, 0, 0);
1297 * Converts tiled data to linear
1298 * 1. uv of nt12t to uv of yuv420p
1301 * u address of yuv420p[out]
1304 * v address of yuv420p[out]
1307 * uv address of nt12t[in]
1309 * @param yuv420_width
1310 * real width of yuv420p[in]
1312 * @param yuv420_height
1313 * real height of yuv420p[in]
1315 void csc_tiled_to_linear_uv_deinterleave(
1316 unsigned char *u_dst,
1317 unsigned char *v_dst,
1318 unsigned char *uv_src,
1320 unsigned int height)
1322 csc_tiled_to_linear_deinterleave_crop(u_dst, v_dst, uv_src, width, height,
1327 * Converts linear data to tiled
1328 * 1. y of yuv420 to y of nv12t
1331 * y address of nv12t[out]
1334 * y address of yuv420[in]
1336 * @param yuv420_width
1337 * real width of yuv420[in]
1340 * @param yuv420_height
1341 * real height of yuv420[in]
1342 * it should be even.
1345 void csc_linear_to_tiled_y(
1346 unsigned char *y_dst,
1347 unsigned char *y_src,
1349 unsigned int height)
1351 csc_linear_to_tiled_crop(y_dst, y_src, width, height, 0, 0, 0, 0);
1355 * Converts and interleaves linear data to tiled
1356 * 1. uv of nv12t to uv of yuv420
1359 * uv address of nv12t[out]
1362 * u address of yuv420[in]
1365 * v address of yuv420[in]
1367 * @param yuv420_width
1368 * real width of yuv420[in]
1370 * @param yuv420_height
1371 * real height of yuv420[in]
1374 void csc_linear_to_tiled_uv(
1375 unsigned char *uv_dst,
1376 unsigned char *u_src,
1377 unsigned char *v_src,
1379 unsigned int height)
1381 csc_linear_to_tiled_interleave_crop(uv_dst, u_src, v_src, width, height,
1387 * Converts tiled data to linear for mfc 6.x
1388 * 1. Y of NV12T to Y of YUV420P
1389 * 2. Y of NV12T to Y of YUV420S
1392 * Y address of YUV420[out]
1395 * Y address of NV12T[in]
1397 * @param yuv420_width
1398 * real width of YUV420[in]
1400 * @param yuv420_height
1401 * Y: real height of YUV420[in]
1404 void csc_tiled_to_linear_y_neon(
1405 unsigned char *y_dst,
1406 unsigned char *y_src,
1408 unsigned int height)
1410 csc_tiled_to_linear_crop_neon(y_dst, y_src, width, height, 0, 0, 0, 0);
1414 * Converts tiled data to linear for mfc 6.x
1415 * 1. UV of NV12T to Y of YUV420S
1418 * UV plane address of YUV420P[out]
1421 * Y or UV plane address of NV12T[in]
1423 * @param yuv420_width
1424 * real width of YUV420[in]
1426 * @param yuv420_height
1427 * (real height)/2 of YUV420[in]
1429 void csc_tiled_to_linear_uv_neon(
1430 unsigned char *uv_dst,
1431 unsigned char *uv_src,
1433 unsigned int height)
1435 csc_tiled_to_linear_crop_neon(uv_dst, uv_src, width, height, 0, 0, 0, 0);
1439 * Converts tiled data to linear for mfc 6.x
1440 * Deinterleave src to u_dst, v_dst
1441 * 1. UV of NV12T to Y of YUV420P
1444 * U plane address of YUV420P[out]
1447 * V plane address of YUV420P[out]
1450 * Y or UV plane address of NV12T[in]
1452 * @param yuv420_width
1453 * real width of YUV420[in]
1455 * @param yuv420_height
1456 * (real height)/2 of YUV420[in]
1458 void csc_tiled_to_linear_uv_deinterleave_neon(
1459 unsigned char *u_dst,
1460 unsigned char *v_dst,
1461 unsigned char *uv_src,
1463 unsigned int height)
1465 csc_tiled_to_linear_deinterleave_crop_neon(u_dst, v_dst, uv_src, width, height,
1470 * Converts linear data to tiled
1471 * 1. y of yuv420 to y of nv12t
1474 * y address of nv12t[out]
1477 * y address of yuv420[in]
1479 * @param yuv420_width
1480 * real width of yuv420[in]
1483 * @param yuv420_height
1484 * real height of yuv420[in]
1485 * it should be even.
1488 void csc_linear_to_tiled_y_neon(
1489 unsigned char *y_dst,
1490 unsigned char *y_src,
1492 unsigned int height)
1494 csc_linear_to_tiled_crop_neon(y_dst, y_src, width, height, 0, 0, 0, 0);
1498 * Converts and interleaves linear data to tiled
1499 * 1. uv of nv12t to uv of yuv420
1502 * uv address of nv12t[out]
1505 * u address of yuv420[in]
1508 * v address of yuv420[in]
1510 * @param yuv420_width
1511 * real width of yuv420[in]
1513 * @param yuv420_height
1514 * real height of yuv420[in]
1517 void csc_linear_to_tiled_uv_neon(
1518 unsigned char *uv_dst,
1519 unsigned char *u_src,
1520 unsigned char *v_src,
1522 unsigned int height)
1524 csc_linear_to_tiled_interleave_crop_neon(uv_dst, u_src, v_src,
1525 width, height, 0, 0, 0, 0);
1530 * Converts RGB565 to YUV420P
1533 * Y plane address of YUV420P[out]
1536 * U plane address of YUV420P[out]
1539 * V plane address of YUV420P[out]
1542 * Address of RGB565[in]
1545 * Width of RGB565[in]
1548 * Height of RGB565[in]
1550 void csc_RGB565_to_YUV420P(
1551 unsigned char *y_dst,
1552 unsigned char *u_dst,
1553 unsigned char *v_dst,
1554 unsigned char *rgb_src,
1556 unsigned int height)
1561 unsigned int R, G, B;
1562 unsigned int Y, U, V;
1564 unsigned short int *pSrc = (unsigned short int *)rgb_src;
1566 unsigned char *pDstY = (unsigned char *)y_dst;
1567 unsigned char *pDstU = (unsigned char *)u_dst;
1568 unsigned char *pDstV = (unsigned char *)v_dst;
1570 unsigned int yIndex = 0;
1571 unsigned int uIndex = 0;
1572 unsigned int vIndex = 0;
1574 for (j = 0; j < height; j++) {
1575 for (i = 0; i < width; i++) {
1576 tmp = pSrc[j * width + i];
1578 R = (tmp & 0x0000F800) >> 8;
1579 G = (tmp & 0x000007E0) >> 3;
1580 B = (tmp & 0x0000001F);
1583 Y = ((66 * R) + (129 * G) + (25 * B) + 128);
1587 pDstY[yIndex++] = (unsigned char)Y;
1589 if ((j % 2) == 0 && (i % 2) == 0) {
1590 U = ((-38 * R) - (74 * G) + (112 * B) + 128);
1593 V = ((112 * R) - (94 * G) - (18 * B) + 128);
1597 pDstU[uIndex++] = (unsigned char)U;
1598 pDstV[vIndex++] = (unsigned char)V;
1605 * Converts RGB565 to YUV420SP
1608 * Y plane address of YUV420SP[out]
1611 * UV plane address of YUV420SP[out]
1614 * Address of RGB565[in]
1617 * Width of RGB565[in]
1620 * Height of RGB565[in]
1622 void csc_RGB565_to_YUV420SP(
1623 unsigned char *y_dst,
1624 unsigned char *uv_dst,
1625 unsigned char *rgb_src,
1627 unsigned int height)
1632 unsigned int R, G, B;
1633 unsigned int Y, U, V;
1635 unsigned short int *pSrc = (unsigned short int *)rgb_src;
1637 unsigned char *pDstY = (unsigned char *)y_dst;
1638 unsigned char *pDstUV = (unsigned char *)uv_dst;
1640 unsigned int yIndex = 0;
1641 unsigned int uvIndex = 0;
1643 for (j = 0; j < height; j++) {
1644 for (i = 0; i < width; i++) {
1645 tmp = pSrc[j * width + i];
1647 R = (tmp & 0x0000F800) >> 11;
1649 G = (tmp & 0x000007E0) >> 5;
1651 B = (tmp & 0x0000001F);
1654 Y = ((66 * R) + (129 * G) + (25 * B) + 128);
1658 pDstY[yIndex++] = (unsigned char)Y;
1660 if ((j % 2) == 0 && (i % 2) == 0) {
1661 U = ((-38 * R) - (74 * G) + (112 * B) + 128);
1664 V = ((112 * R) - (94 * G) - (18 * B) + 128);
1668 pDstUV[uvIndex++] = (unsigned char)U;
1669 pDstUV[uvIndex++] = (unsigned char)V;
1676 * Converts ARGB8888 to YUV420P
1679 * Y plane address of YUV420P[out]
1682 * U plane address of YUV420P[out]
1685 * V plane address of YUV420P[out]
1688 * Address of ARGB8888[in]
1691 * Width of ARGB8888[in]
1694 * Height of ARGB8888[in]
1696 void csc_ARGB8888_to_YUV420P(
1697 unsigned char *y_dst,
1698 unsigned char *u_dst,
1699 unsigned char *v_dst,
1700 unsigned char *rgb_src,
1702 unsigned int height)
1707 unsigned int R, G, B;
1708 unsigned int Y, U, V;
1710 unsigned int *pSrc = (unsigned int *)rgb_src;
1712 unsigned char *pDstY = (unsigned char *)y_dst;
1713 unsigned char *pDstU = (unsigned char *)u_dst;
1714 unsigned char *pDstV = (unsigned char *)v_dst;
1716 unsigned int yIndex = 0;
1717 unsigned int uIndex = 0;
1718 unsigned int vIndex = 0;
1720 for (j = 0; j < height; j++) {
1721 for (i = 0; i < width; i++) {
1722 tmp = pSrc[j * width + i];
1724 R = (tmp & 0x00FF0000) >> 16;
1725 G = (tmp & 0x0000FF00) >> 8;
1726 B = (tmp & 0x000000FF);
1728 Y = ((66 * R) + (129 * G) + (25 * B) + 128);
1732 pDstY[yIndex++] = (unsigned char)Y;
1734 if ((j % 2) == 0 && (i % 2) == 0) {
1735 U = ((-38 * R) - (74 * G) + (112 * B) + 128);
1738 V = ((112 * R) - (94 * G) - (18 * B) + 128);
1742 pDstU[uIndex++] = (unsigned char)U;
1743 pDstV[vIndex++] = (unsigned char)V;
1751 * Converts ARGB8888 to YUV420SP
1754 * Y plane address of YUV420SP[out]
1757 * UV plane address of YUV420SP[out]
1760 * Address of ARGB8888[in]
1763 * Width of ARGB8888[in]
1766 * Height of ARGB8888[in]
1768 void csc_ARGB8888_to_YUV420SP(
1769 unsigned char *y_dst,
1770 unsigned char *uv_dst,
1771 unsigned char *rgb_src,
1773 unsigned int height)
1778 unsigned int R, G, B;
1779 unsigned int Y, U, V;
1781 unsigned int *pSrc = (unsigned int *)rgb_src;
1783 unsigned char *pDstY = (unsigned char *)y_dst;
1784 unsigned char *pDstUV = (unsigned char *)uv_dst;
1786 unsigned int yIndex = 0;
1787 unsigned int uvIndex = 0;
1789 for (j = 0; j < height; j++) {
1790 for (i = 0; i < width; i++) {
1791 tmp = pSrc[j * width + i];
1793 R = (tmp & 0x00FF0000) >> 16;
1794 G = (tmp & 0x0000FF00) >> 8;
1795 B = (tmp & 0x000000FF);
1797 Y = ((66 * R) + (129 * G) + (25 * B) + 128);
1801 pDstY[yIndex++] = (unsigned char)Y;
1803 if ((j % 2) == 0 && (i % 2) == 0) {
1804 U = ((-38 * R) - (74 * G) + (112 * B) + 128);
1807 V = ((112 * R) - (94 * G) - (18 * B) + 128);
1811 pDstUV[uvIndex++] = (unsigned char)U;
1812 pDstUV[uvIndex++] = (unsigned char)V;