Index: source/convert.cc |
diff --git a/source/convert.cc b/source/convert.cc |
index 156cc98bfd14e568b44bbc5b2e66cf078419eb5b..d6ae9d19245b8604db310812e6fe1b6b1e7813ea 100644 |
--- a/source/convert.cc |
+++ b/source/convert.cc |
@@ -226,15 +226,14 @@ static void CopyPlane2(const uint8* src, int src_stride_0, int src_stride_1, |
} |
} |
-// Support function for NV12 etc UV channels. |
-// Width and height are plane sizes (typically half pixel width). |
fbarchard1
2016/08/24 17:42:23
suggest keeping the comments.
|
-static void SplitPlane(const uint8* src_uv, int src_stride_uv, |
- uint8* dst_u, int dst_stride_u, |
- uint8* dst_v, int dst_stride_v, |
- int width, int height) { |
- int y; |
- void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, |
- int width) = SplitUVRow_C; |
+LIBYUV_API |
+int SplitUVPlanes(const uint8* src_uv, int src_stride_uv, |
+ uint8* dst_u, int dst_stride_u, |
+ uint8* dst_v, int dst_stride_v, |
+ int width, int height) { |
+ if (!src_uv || !dst_u || !dst_v || width <= 0 || height == 0) { |
+ return -1; |
+ } |
// Negative height means invert the image. |
if (height < 0) { |
height = -height; |
@@ -251,48 +250,17 @@ static void SplitPlane(const uint8* src_uv, int src_stride_uv, |
height = 1; |
src_stride_uv = dst_stride_u = dst_stride_v = 0; |
} |
-#if defined(HAS_SPLITUVROW_SSE2) |
- if (TestCpuFlag(kCpuHasSSE2)) { |
- SplitUVRow = SplitUVRow_Any_SSE2; |
- if (IS_ALIGNED(width, 16)) { |
- SplitUVRow = SplitUVRow_SSE2; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_AVX2) |
- if (TestCpuFlag(kCpuHasAVX2)) { |
- SplitUVRow = SplitUVRow_Any_AVX2; |
- if (IS_ALIGNED(width, 32)) { |
- SplitUVRow = SplitUVRow_AVX2; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_NEON) |
- if (TestCpuFlag(kCpuHasNEON)) { |
- SplitUVRow = SplitUVRow_Any_NEON; |
- if (IS_ALIGNED(width, 16)) { |
- SplitUVRow = SplitUVRow_NEON; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_DSPR2) |
- if (TestCpuFlag(kCpuHasDSPR2) && |
- IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) && |
- IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) { |
- SplitUVRow = SplitUVRow_Any_DSPR2; |
- if (IS_ALIGNED(width, 16)) { |
- SplitUVRow = SplitUVRow_DSPR2; |
- } |
- } |
-#endif |
+ SplitUVRowFunction SplitUVRow = GetOptimizedSplitUVRowFunction( |
fbarchard1
2016/08/24 17:42:23
prefer not use getter function.
|
+ src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, dst_stride_v, width); |
- for (y = 0; y < height; ++y) { |
+ for (int y = 0; y < height; ++y) { |
fbarchard1
2016/08/24 17:42:23
declare y at top for c89 compatibility.
|
// Copy a row of UV. |
SplitUVRow(src_uv, dst_u, dst_v, width); |
dst_u += dst_stride_u; |
dst_v += dst_stride_v; |
src_uv += src_stride_uv; |
} |
+ return 0; |
} |
// Support converting from FOURCC_M420 |
@@ -314,8 +282,6 @@ static int X420ToI420(const uint8* src_y, |
int y; |
int halfwidth = (width + 1) >> 1; |
int halfheight = (height + 1) >> 1; |
- void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, |
- int width) = SplitUVRow_C; |
if (!src_y || !src_uv || |
!dst_y || !dst_u || !dst_v || |
width <= 0 || height == 0) { |
@@ -348,41 +314,11 @@ static int X420ToI420(const uint8* src_y, |
halfheight = 1; |
src_stride_uv = dst_stride_u = dst_stride_v = 0; |
} |
-#if defined(HAS_SPLITUVROW_SSE2) |
- if (TestCpuFlag(kCpuHasSSE2)) { |
- SplitUVRow = SplitUVRow_Any_SSE2; |
- if (IS_ALIGNED(halfwidth, 16)) { |
- SplitUVRow = SplitUVRow_SSE2; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_AVX2) |
- if (TestCpuFlag(kCpuHasAVX2)) { |
- SplitUVRow = SplitUVRow_Any_AVX2; |
- if (IS_ALIGNED(halfwidth, 32)) { |
- SplitUVRow = SplitUVRow_AVX2; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_NEON) |
- if (TestCpuFlag(kCpuHasNEON)) { |
- SplitUVRow = SplitUVRow_Any_NEON; |
- if (IS_ALIGNED(halfwidth, 16)) { |
- SplitUVRow = SplitUVRow_NEON; |
- } |
- } |
-#endif |
-#if defined(HAS_SPLITUVROW_DSPR2) |
- if (TestCpuFlag(kCpuHasDSPR2) && |
- IS_ALIGNED(src_uv, 4) && IS_ALIGNED(src_stride_uv, 4) && |
- IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) && |
- IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) { |
- SplitUVRow = SplitUVRow_Any_DSPR2; |
- if (IS_ALIGNED(halfwidth, 16)) { |
- SplitUVRow = SplitUVRow_DSPR2; |
- } |
- } |
-#endif |
+ SplitUVRowFunction SplitUVRow = GetOptimizedSplitUVRowFunction( |
+ src_uv, src_stride_uv, |
+ dst_u, dst_stride_u, |
+ dst_v, dst_stride_v, |
+ halfwidth); |
if (dst_y) { |
if (src_stride_y0 == src_stride_y1) { |
@@ -1505,14 +1441,14 @@ int Android420ToI420(const uint8* src_y, int src_stride_y, |
// Split UV planes - NV21 |
} else if (src_pixel_stride_uv == 2 && vu_off == -1 && |
src_stride_u == src_stride_v) { |
- SplitPlane(src_v, src_stride_v, dst_v, dst_stride_v, dst_u, dst_stride_u, |
- halfwidth, halfheight); |
+ SplitUVPlanes(src_v, src_stride_v, dst_v, dst_stride_v, dst_u, dst_stride_u, |
+ halfwidth, halfheight); |
return 0; |
// Split UV planes - NV12 |
} else if (src_pixel_stride_uv == 2 && vu_off == 1 && |
src_stride_u == src_stride_v) { |
- SplitPlane(src_u, src_stride_u, dst_u, dst_stride_u, dst_v, dst_stride_v, |
- halfwidth, halfheight); |
+ SplitUVPlanes(src_u, src_stride_u, dst_u, dst_stride_u, dst_v, dst_stride_v, |
+ halfwidth, halfheight); |
return 0; |
} |