Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: source/row_common.cc

Issue 2266533003: Add SplitUVPlanes and MergeUVPlanes (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« source/planar_functions.cc ('K') | « source/planar_functions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "libyuv/row.h" 11 #include "libyuv/row.h"
12 12
13 #include <string.h> // For memcpy and memset. 13 #include <string.h> // For memcpy and memset.
14 14
15 #include "libyuv/basic_types.h" 15 #include "libyuv/basic_types.h"
16 #include "libyuv/cpu_id.h"
16 17
17 #ifdef __cplusplus 18 #ifdef __cplusplus
18 namespace libyuv { 19 namespace libyuv {
19 extern "C" { 20 extern "C" {
20 #endif 21 #endif
21 22
22 // llvm x86 is poor at ternary operator, so use branchless min/max. 23 // llvm x86 is poor at ternary operator, so use branchless min/max.
23 24
24 #define USE_BRANCHLESS 1 25 #define USE_BRANCHLESS 1
25 #if USE_BRANCHLESS 26 #if USE_BRANCHLESS
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 dst_v[x] = src_uv[1]; 1794 dst_v[x] = src_uv[1];
1794 dst_v[x + 1] = src_uv[3]; 1795 dst_v[x + 1] = src_uv[3];
1795 src_uv += 4; 1796 src_uv += 4;
1796 } 1797 }
1797 if (width & 1) { 1798 if (width & 1) {
1798 dst_u[width - 1] = src_uv[0]; 1799 dst_u[width - 1] = src_uv[0];
1799 dst_v[width - 1] = src_uv[1]; 1800 dst_v[width - 1] = src_uv[1];
1800 } 1801 }
1801 } 1802 }
1802 1803
1804 SplitUVRowFunction GetOptimizedSplitUVRowFunction(
fbarchard1 2016/08/24 17:42:24 suggest removing. common is not meant for this so
1805 const uint8 *src_uv, int src_stride_uv,
1806 const uint8 *dst_u, int dst_stride_u,
1807 const uint8 *dst_v, int dst_stride_v,
1808 int width) {
1809 #if defined(HAS_SPLITUVROW_DSPR2)
1810 if (TestCpuFlag(kCpuHasDSPR2) &&
1811 IS_ALIGNED(src_uv, 4) && IS_ALIGNED(src_stride_uv, 4) &&
1812 IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) &&
1813 IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) {
1814 return IS_ALIGNED(width, 16) ? SplitUVRow_DSPR2 : SplitUVRow_Any_DSPR2;
1815 }
1816 #endif
1817 #if defined(HAS_SPLITUVROW_NEON)
1818 if (TestCpuFlag(kCpuHasNEON)) {
1819 return IS_ALIGNED(width, 16) ? SplitUVRow_NEON : SplitUVRow_Any_NEON;
1820 }
1821 #endif
1822 #if defined(HAS_SPLITUVROW_AVX2)
1823 if (TestCpuFlag(kCpuHasAVX2)) {
1824 return IS_ALIGNED(width, 32) ? SplitUVRow_AVX2 : SplitUVRow_Any_AVX2;
1825 }
1826 #endif
1827 #if defined(HAS_SPLITUVROW_SSE2)
1828 if (TestCpuFlag(kCpuHasSSE2)) {
1829 return IS_ALIGNED(width, 16) ? SplitUVRow_SSE2 : SplitUVRow_Any_SSE2;
1830 }
1831 #endif
1832 return SplitUVRow_C;
1833 }
1834
1803 void MergeUVRow_C(const uint8* src_u, const uint8* src_v, uint8* dst_uv, 1835 void MergeUVRow_C(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
1804 int width) { 1836 int width) {
1805 int x; 1837 int x;
1806 for (x = 0; x < width - 1; x += 2) { 1838 for (x = 0; x < width - 1; x += 2) {
1807 dst_uv[0] = src_u[x]; 1839 dst_uv[0] = src_u[x];
1808 dst_uv[1] = src_v[x]; 1840 dst_uv[1] = src_v[x];
1809 dst_uv[2] = src_u[x + 1]; 1841 dst_uv[2] = src_u[x + 1];
1810 dst_uv[3] = src_v[x + 1]; 1842 dst_uv[3] = src_v[x + 1];
1811 dst_uv += 4; 1843 dst_uv += 4;
1812 } 1844 }
1813 if (width & 1) { 1845 if (width & 1) {
1814 dst_uv[0] = src_u[width - 1]; 1846 dst_uv[0] = src_u[width - 1];
1815 dst_uv[1] = src_v[width - 1]; 1847 dst_uv[1] = src_v[width - 1];
1816 } 1848 }
1817 } 1849 }
1818 1850
1851 MergeUVRowFunction GetOptimizedMergeUVRowFunction(int width) {
1852 #if defined(HAS_MERGEUVROW_NEON)
1853 if (TestCpuFlag(kCpuHasNEON)) {
1854 return IS_ALIGNED(width, 16) ? MergeUVRow_NEON : MergeUVRow_Any_NEON;
1855 }
1856 #endif
1857 #if defined(HAS_MERGEUVROW_AVX2)
1858 if (TestCpuFlag(kCpuHasAVX2)) {
1859 return IS_ALIGNED(width, 32) ? MergeUVRow_AVX2 : MergeUVRow_Any_AVX2;
1860 }
1861 #endif
1862 #if defined(HAS_MERGEUVROW_SSE2)
1863 if (TestCpuFlag(kCpuHasSSE2)) {
1864 return IS_ALIGNED(width, 16) ? MergeUVRow_SSE2 : MergeUVRow_Any_SSE2;
1865 }
1866 #endif
1867 return MergeUVRow_C;
1868 }
1869
1819 void CopyRow_C(const uint8* src, uint8* dst, int count) { 1870 void CopyRow_C(const uint8* src, uint8* dst, int count) {
1820 memcpy(dst, src, count); 1871 memcpy(dst, src, count);
1821 } 1872 }
1822 1873
1823 void CopyRow_16_C(const uint16* src, uint16* dst, int count) { 1874 void CopyRow_16_C(const uint16* src, uint16* dst, int count) {
1824 memcpy(dst, src, count * 2); 1875 memcpy(dst, src, count * 2);
1825 } 1876 }
1826 1877
1827 void SetRow_C(uint8* dst, uint8 v8, int width) { 1878 void SetRow_C(uint8* dst, uint8 v8, int width) {
1828 memset(dst, v8, width); 1879 memset(dst, v8, width);
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 dst_rgb565 += twidth * 2; 2669 dst_rgb565 += twidth * 2;
2619 width -= twidth; 2670 width -= twidth;
2620 } 2671 }
2621 } 2672 }
2622 #endif 2673 #endif
2623 2674
2624 #ifdef __cplusplus 2675 #ifdef __cplusplus
2625 } // extern "C" 2676 } // extern "C"
2626 } // namespace libyuv 2677 } // namespace libyuv
2627 #endif 2678 #endif
OLDNEW
« source/planar_functions.cc ('K') | « source/planar_functions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698