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

Unified Diff: source/convert.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 side-by-side diff with in-line comments
Download patch
Index: source/convert.cc
diff --git a/source/convert.cc b/source/convert.cc
index 08e5e5d67d5ca3646fcda5eee2dff02f765f8657..9f682a6221055b0ab419a7665e00e78086926447 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:24 keep this comment.
-static void SplitUVPlane(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 SplitUVPlane(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 SplitUVPlane(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(
+ 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:24 int y needs to be declared at top of function for
// 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

Powered by Google App Engine
This is Rietveld 408576698