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

Unified Diff: source/planar_functions.cc

Issue 2277603004: Add SplitUVPlanes and MergeUVPlanes (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: 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/planar_functions.cc
diff --git a/source/planar_functions.cc b/source/planar_functions.cc
index 811ee5b72ccfa5eaf719f785444ad1ef04140a44..387d5d897dc22cf20766f247725bf319c3c1e78c 100644
--- a/source/planar_functions.cc
+++ b/source/planar_functions.cc
@@ -31,6 +31,12 @@ void CopyPlane(const uint8* src_y, int src_stride_y,
int width, int height) {
int y;
void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C;
+ // Negative height means invert the image.
fbarchard1 2016/08/24 23:04:11 this change isnt needed? remove
fbarchard1 2016/08/24 23:11:50 Acknowledged. Currently needed in this CL and con
+ if (height < 0) {
+ height = -height;
+ dst_y = dst_y + (height - 1) * dst_stride_y;
+ dst_stride_y = -dst_stride_y;
+ }
// Coalesce rows.
if (src_stride_y == width &&
dst_stride_y == width) {
@@ -2482,8 +2488,6 @@ int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2,
int width, int height) {
int y;
int halfwidth = (width + 1) >> 1;
- void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
- int width) = SplitUVRow_C;
void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr,
ptrdiff_t src_stride, int dst_width,
int source_y_fraction) = InterpolateRow_C;
@@ -2498,30 +2502,6 @@ int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2,
src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
src_stride_yuy2 = -src_stride_yuy2;
}
-#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_INTERPOLATEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
InterpolateRow = InterpolateRow_Any_SSSE3;
@@ -2552,6 +2532,12 @@ int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2,
// row of y and 2 rows of uv
align_buffer_64(rows, awidth * 3);
+ SplitUVRowFunction SplitUVRow = GetOptimizedSplitUVRowFunction(
+ src_yuy2, src_stride_yuy2,
+ rows, awidth,
+ rows, awidth,
+ awidth);
+
for (y = 0; y < height - 1; y += 2) {
// Split Y from UV.
SplitUVRow(src_yuy2, rows, rows + awidth, awidth);
@@ -2565,8 +2551,9 @@ int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2,
}
if (height & 1) {
// Split Y from UV.
- SplitUVRow(src_yuy2, rows, dst_uv, awidth);
+ SplitUVRow(src_yuy2, rows, rows + awidth, awidth);
memcpy(dst_y, rows, width);
+ memcpy(dst_uv, rows + awidth, awidth);
fbarchard1 2016/08/24 23:04:11 this change isnt needed? remove. if this change i
}
free_aligned_buffer_64(rows);
}
@@ -2580,8 +2567,6 @@ int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy,
int width, int height) {
int y;
int halfwidth = (width + 1) >> 1;
- void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
- int width) = SplitUVRow_C;
void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr,
ptrdiff_t src_stride, int dst_width,
int source_y_fraction) = InterpolateRow_C;
@@ -2596,30 +2581,6 @@ int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy,
src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
src_stride_uyvy = -src_stride_uyvy;
}
-#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_INTERPOLATEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
InterpolateRow = InterpolateRow_Any_SSSE3;
@@ -2650,6 +2611,12 @@ int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy,
// row of y and 2 rows of uv
align_buffer_64(rows, awidth * 3);
+ SplitUVRowFunction SplitUVRow = GetOptimizedSplitUVRowFunction(
+ src_uyvy, src_stride_uyvy,
+ rows, awidth,
+ rows, awidth,
+ awidth);
+
for (y = 0; y < height - 1; y += 2) {
// Split Y from UV.
SplitUVRow(src_uyvy, rows + awidth, rows, awidth);
@@ -2663,8 +2630,9 @@ int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy,
}
if (height & 1) {
// Split Y from UV.
- SplitUVRow(src_uyvy, dst_uv, rows, awidth);
+ SplitUVRow(src_uyvy, rows + awidth, rows, awidth);
memcpy(dst_y, rows, width);
+ memcpy(dst_uv, rows + awidth, awidth);
}
free_aligned_buffer_64(rows);
}

Powered by Google App Engine
This is Rietveld 408576698