OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 uint8 ag = src_argb[1]; | 629 uint8 ag = src_argb[1]; |
630 uint8 ar = src_argb[2]; | 630 uint8 ar = src_argb[2]; |
631 dst_u[0] = RGBToU(ar, ag, ab); | 631 dst_u[0] = RGBToU(ar, ag, ab); |
632 dst_v[0] = RGBToV(ar, ag, ab); | 632 dst_v[0] = RGBToV(ar, ag, ab); |
633 src_argb += 4; | 633 src_argb += 4; |
634 dst_u += 1; | 634 dst_u += 1; |
635 dst_v += 1; | 635 dst_v += 1; |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 void ARGBToUV411Row_C(const uint8* src_argb, | |
640 uint8* dst_u, uint8* dst_v, int width) { | |
641 int x; | |
642 for (x = 0; x < width - 3; x += 4) { | |
643 uint8 ab = (src_argb[0] + src_argb[4] + src_argb[8] + src_argb[12]) >> 2; | |
644 uint8 ag = (src_argb[1] + src_argb[5] + src_argb[9] + src_argb[13]) >> 2; | |
645 uint8 ar = (src_argb[2] + src_argb[6] + src_argb[10] + src_argb[14]) >> 2; | |
646 dst_u[0] = RGBToU(ar, ag, ab); | |
647 dst_v[0] = RGBToV(ar, ag, ab); | |
648 src_argb += 16; | |
649 dst_u += 1; | |
650 dst_v += 1; | |
651 } | |
652 // Odd width handling mimics 'any' function which replicates last pixel. | |
653 if ((width & 3) == 3) { | |
654 uint8 ab = (src_argb[0] + src_argb[4] + src_argb[8] + src_argb[8]) >> 2; | |
655 uint8 ag = (src_argb[1] + src_argb[5] + src_argb[9] + src_argb[9]) >> 2; | |
656 uint8 ar = (src_argb[2] + src_argb[6] + src_argb[10] + src_argb[10]) >> 2; | |
657 dst_u[0] = RGBToU(ar, ag, ab); | |
658 dst_v[0] = RGBToV(ar, ag, ab); | |
659 } else if ((width & 3) == 2) { | |
660 uint8 ab = (src_argb[0] + src_argb[4]) >> 1; | |
661 uint8 ag = (src_argb[1] + src_argb[5]) >> 1; | |
662 uint8 ar = (src_argb[2] + src_argb[6]) >> 1; | |
663 dst_u[0] = RGBToU(ar, ag, ab); | |
664 dst_v[0] = RGBToV(ar, ag, ab); | |
665 } else if ((width & 3) == 1) { | |
666 uint8 ab = src_argb[0]; | |
667 uint8 ag = src_argb[1]; | |
668 uint8 ar = src_argb[2]; | |
669 dst_u[0] = RGBToU(ar, ag, ab); | |
670 dst_v[0] = RGBToV(ar, ag, ab); | |
671 } | |
672 } | |
673 | |
674 void ARGBGrayRow_C(const uint8* src_argb, uint8* dst_argb, int width) { | 639 void ARGBGrayRow_C(const uint8* src_argb, uint8* dst_argb, int width) { |
675 int x; | 640 int x; |
676 for (x = 0; x < width; ++x) { | 641 for (x = 0; x < width; ++x) { |
677 uint8 y = RGBToYJ(src_argb[2], src_argb[1], src_argb[0]); | 642 uint8 y = RGBToYJ(src_argb[2], src_argb[1], src_argb[0]); |
678 dst_argb[2] = dst_argb[1] = dst_argb[0] = y; | 643 dst_argb[2] = dst_argb[1] = dst_argb[0] = y; |
679 dst_argb[3] = src_argb[3]; | 644 dst_argb[3] = src_argb[3]; |
680 dst_argb += 4; | 645 dst_argb += 4; |
681 src_argb += 4; | 646 src_argb += 4; |
682 } | 647 } |
683 } | 648 } |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 } | 1488 } |
1524 if (width & 1) { | 1489 if (width & 1) { |
1525 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); | 1490 YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0, yuvconstants); |
1526 b0 = b0 >> 3; | 1491 b0 = b0 >> 3; |
1527 g0 = g0 >> 2; | 1492 g0 = g0 >> 2; |
1528 r0 = r0 >> 3; | 1493 r0 = r0 >> 3; |
1529 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); | 1494 *(uint16*)(dst_rgb565) = b0 | (g0 << 5) | (r0 << 11); |
1530 } | 1495 } |
1531 } | 1496 } |
1532 | 1497 |
1533 void I411ToARGBRow_C(const uint8* src_y, | |
1534 const uint8* src_u, | |
1535 const uint8* src_v, | |
1536 uint8* rgb_buf, | |
1537 const struct YuvConstants* yuvconstants, | |
1538 int width) { | |
1539 int x; | |
1540 for (x = 0; x < width - 3; x += 4) { | |
1541 YuvPixel(src_y[0], src_u[0], src_v[0], | |
1542 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); | |
1543 rgb_buf[3] = 255; | |
1544 YuvPixel(src_y[1], src_u[0], src_v[0], | |
1545 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); | |
1546 rgb_buf[7] = 255; | |
1547 YuvPixel(src_y[2], src_u[0], src_v[0], | |
1548 rgb_buf + 8, rgb_buf + 9, rgb_buf + 10, yuvconstants); | |
1549 rgb_buf[11] = 255; | |
1550 YuvPixel(src_y[3], src_u[0], src_v[0], | |
1551 rgb_buf + 12, rgb_buf + 13, rgb_buf + 14, yuvconstants); | |
1552 rgb_buf[15] = 255; | |
1553 src_y += 4; | |
1554 src_u += 1; | |
1555 src_v += 1; | |
1556 rgb_buf += 16; // Advance 4 pixels. | |
1557 } | |
1558 if (width & 2) { | |
1559 YuvPixel(src_y[0], src_u[0], src_v[0], | |
1560 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); | |
1561 rgb_buf[3] = 255; | |
1562 YuvPixel(src_y[1], src_u[0], src_v[0], | |
1563 rgb_buf + 4, rgb_buf + 5, rgb_buf + 6, yuvconstants); | |
1564 rgb_buf[7] = 255; | |
1565 src_y += 2; | |
1566 rgb_buf += 8; // Advance 2 pixels. | |
1567 } | |
1568 if (width & 1) { | |
1569 YuvPixel(src_y[0], src_u[0], src_v[0], | |
1570 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); | |
1571 rgb_buf[3] = 255; | |
1572 } | |
1573 } | |
1574 | |
1575 void NV12ToARGBRow_C(const uint8* src_y, | 1498 void NV12ToARGBRow_C(const uint8* src_y, |
1576 const uint8* src_uv, | 1499 const uint8* src_uv, |
1577 uint8* rgb_buf, | 1500 uint8* rgb_buf, |
1578 const struct YuvConstants* yuvconstants, | 1501 const struct YuvConstants* yuvconstants, |
1579 int width) { | 1502 int width) { |
1580 int x; | 1503 int x; |
1581 for (x = 0; x < width - 1; x += 2) { | 1504 for (x = 0; x < width - 1; x += 2) { |
1582 YuvPixel(src_y[0], src_uv[0], src_uv[1], | 1505 YuvPixel(src_y[0], src_uv[0], src_uv[1], |
1583 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); | 1506 rgb_buf + 0, rgb_buf + 1, rgb_buf + 2, yuvconstants); |
1584 rgb_buf[3] = 255; | 1507 rgb_buf[3] = 255; |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 dst_rgb565 += twidth * 2; | 2561 dst_rgb565 += twidth * 2; |
2639 width -= twidth; | 2562 width -= twidth; |
2640 } | 2563 } |
2641 } | 2564 } |
2642 #endif | 2565 #endif |
2643 | 2566 |
2644 #ifdef __cplusplus | 2567 #ifdef __cplusplus |
2645 } // extern "C" | 2568 } // extern "C" |
2646 } // namespace libyuv | 2569 } // namespace libyuv |
2647 #endif | 2570 #endif |
OLD | NEW |