From 3d190ee9f1f9e9e1be1c67cfd4cd24b039d7bc6f Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Tue, 14 Jul 2015 10:23:10 -0700 Subject: break rotate into files by cpu in preparation for optimization. R=bcornell@google.com BUG=libyuv:464 Review URL: https://webrtc-codereview.appspot.com/51289004. --- source/rotate_common.cc | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 source/rotate_common.cc (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc new file mode 100644 index 00000000..b53326ee --- /dev/null +++ b/source/rotate_common.cc @@ -0,0 +1,97 @@ +/* + * Copyright 2011 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "libyuv/rotate.h" + +#include "libyuv/cpu_id.h" +#include "libyuv/convert.h" +#include "libyuv/planar_functions.h" +#include "libyuv/rotate_row.h" +#include "libyuv/row.h" + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +void TransposeWx8_C(const uint8* src, int src_stride, + uint8* dst, int dst_stride, int width) { + int i; + for (i = 0; i < width; ++i) { + dst[0] = src[0 * src_stride]; + dst[1] = src[1 * src_stride]; + dst[2] = src[2 * src_stride]; + dst[3] = src[3 * src_stride]; + dst[4] = src[4 * src_stride]; + dst[5] = src[5 * src_stride]; + dst[6] = src[6 * src_stride]; + dst[7] = src[7 * src_stride]; + ++src; + dst += dst_stride; + } +} + +void TransposeUVWx8_C(const uint8* src, int src_stride, + uint8* dst_a, int dst_stride_a, + uint8* dst_b, int dst_stride_b, int width) { + int i; + for (i = 0; i < width; ++i) { + dst_a[0] = src[0 * src_stride + 0]; + dst_b[0] = src[0 * src_stride + 1]; + dst_a[1] = src[1 * src_stride + 0]; + dst_b[1] = src[1 * src_stride + 1]; + dst_a[2] = src[2 * src_stride + 0]; + dst_b[2] = src[2 * src_stride + 1]; + dst_a[3] = src[3 * src_stride + 0]; + dst_b[3] = src[3 * src_stride + 1]; + dst_a[4] = src[4 * src_stride + 0]; + dst_b[4] = src[4 * src_stride + 1]; + dst_a[5] = src[5 * src_stride + 0]; + dst_b[5] = src[5 * src_stride + 1]; + dst_a[6] = src[6 * src_stride + 0]; + dst_b[6] = src[6 * src_stride + 1]; + dst_a[7] = src[7 * src_stride + 0]; + dst_b[7] = src[7 * src_stride + 1]; + src += 2; + dst_a += dst_stride_a; + dst_b += dst_stride_b; + } +} + +void TransposeWxH_C(const uint8* src, int src_stride, + uint8* dst, int dst_stride, + int width, int height) { + int i; + for (i = 0; i < width; ++i) { + int j; + for (j = 0; j < height; ++j) { + dst[i * dst_stride + j] = src[j * src_stride + i]; + } + } +} + +void TransposeUVWxH_C(const uint8* src, int src_stride, + uint8* dst_a, int dst_stride_a, + uint8* dst_b, int dst_stride_b, + int width, int height) { + int i; + for (i = 0; i < width * 2; i += 2) { + int j; + for (j = 0; j < height; ++j) { + dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)]; + dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1]; + } + } +} + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif -- cgit v1.2.3 From 3a3a89ccd40764579077e93bc303564c873aa7c1 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 22 Jul 2015 18:09:04 -0700 Subject: rotate include and proto cleanup R=harryjin@google.com BUG=libyuv:468 Review URL: https://webrtc-codereview.appspot.com/55679005. --- source/rotate_common.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index b53326ee..b33a9a0c 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -8,13 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/rotate.h" - -#include "libyuv/cpu_id.h" -#include "libyuv/convert.h" -#include "libyuv/planar_functions.h" -#include "libyuv/rotate_row.h" #include "libyuv/row.h" +#include "libyuv/rotate_row.h" #ifdef __cplusplus namespace libyuv { -- cgit v1.2.3 From e62309f2591d8b87acae5f4560ab9eeed8f91471 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 7 Nov 2016 17:37:23 -0800 Subject: clang-format libyuv BUG=libyuv:654 R=kjellander@chromium.org Review URL: https://codereview.chromium.org/2469353005 . --- source/rotate_common.cc | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index b33a9a0c..cdd231fa 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -16,8 +16,11 @@ namespace libyuv { extern "C" { #endif -void TransposeWx8_C(const uint8* src, int src_stride, - uint8* dst, int dst_stride, int width) { +void TransposeWx8_C(const uint8* src, + int src_stride, + uint8* dst, + int dst_stride, + int width) { int i; for (i = 0; i < width; ++i) { dst[0] = src[0 * src_stride]; @@ -33,9 +36,13 @@ void TransposeWx8_C(const uint8* src, int src_stride, } } -void TransposeUVWx8_C(const uint8* src, int src_stride, - uint8* dst_a, int dst_stride_a, - uint8* dst_b, int dst_stride_b, int width) { +void TransposeUVWx8_C(const uint8* src, + int src_stride, + uint8* dst_a, + int dst_stride_a, + uint8* dst_b, + int dst_stride_b, + int width) { int i; for (i = 0; i < width; ++i) { dst_a[0] = src[0 * src_stride + 0]; @@ -60,9 +67,12 @@ void TransposeUVWx8_C(const uint8* src, int src_stride, } } -void TransposeWxH_C(const uint8* src, int src_stride, - uint8* dst, int dst_stride, - int width, int height) { +void TransposeWxH_C(const uint8* src, + int src_stride, + uint8* dst, + int dst_stride, + int width, + int height) { int i; for (i = 0; i < width; ++i) { int j; @@ -72,10 +82,14 @@ void TransposeWxH_C(const uint8* src, int src_stride, } } -void TransposeUVWxH_C(const uint8* src, int src_stride, - uint8* dst_a, int dst_stride_a, - uint8* dst_b, int dst_stride_b, - int width, int height) { +void TransposeUVWxH_C(const uint8* src, + int src_stride, + uint8* dst_a, + int dst_stride_a, + uint8* dst_b, + int dst_stride_b, + int width, + int height) { int i; for (i = 0; i < width * 2; i += 2) { int j; -- cgit v1.2.3 From 73a603e1204e6eed1eeb1448051b8099aa67cf71 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 8 Mar 2017 09:49:02 -0800 Subject: clang-format 5.0 applied to libyuv BUG=None TEST=try bots and lint test Change-Id: I1ab462adf2d309117862c5eb4b244a61ae202951 Reviewed-on: https://chromium-review.googlesource.com/450658 Commit-Queue: Frank Barchard Reviewed-by: Henrik Kjellander --- source/rotate_common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index cdd231fa..89357e73 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "libyuv/row.h" #include "libyuv/rotate_row.h" +#include "libyuv/row.h" #ifdef __cplusplus namespace libyuv { -- cgit v1.2.3 From 7e389884a14285de2085052c819abee4e53139af Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 22 Jan 2018 18:35:52 -0800 Subject: Switch to C99 types Append _t to all sized types. uint64 becomes uint64_t etc Bug: libyuv:774 Test: try bots build on all platforms Change-Id: Ide273d7f8012313d6610415d514a956d6f3a8cac Reviewed-on: https://chromium-review.googlesource.com/879922 Reviewed-by: Miguel Casas --- source/rotate_common.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index 89357e73..ff212ade 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -16,9 +16,9 @@ namespace libyuv { extern "C" { #endif -void TransposeWx8_C(const uint8* src, +void TransposeWx8_C(const uint8_t* src, int src_stride, - uint8* dst, + uint8_t* dst, int dst_stride, int width) { int i; @@ -36,11 +36,11 @@ void TransposeWx8_C(const uint8* src, } } -void TransposeUVWx8_C(const uint8* src, +void TransposeUVWx8_C(const uint8_t* src, int src_stride, - uint8* dst_a, + uint8_t* dst_a, int dst_stride_a, - uint8* dst_b, + uint8_t* dst_b, int dst_stride_b, int width) { int i; @@ -67,9 +67,9 @@ void TransposeUVWx8_C(const uint8* src, } } -void TransposeWxH_C(const uint8* src, +void TransposeWxH_C(const uint8_t* src, int src_stride, - uint8* dst, + uint8_t* dst, int dst_stride, int width, int height) { @@ -82,11 +82,11 @@ void TransposeWxH_C(const uint8* src, } } -void TransposeUVWxH_C(const uint8* src, +void TransposeUVWxH_C(const uint8_t* src, int src_stride, - uint8* dst_a, + uint8_t* dst_a, int dst_stride_a, - uint8* dst_b, + uint8_t* dst_b, int dst_stride_b, int width, int height) { -- cgit v1.2.3 From f8626a72248f7063c9bf3bbe96333a4af6e8b36f Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Wed, 4 Jan 2023 08:53:51 +0100 Subject: Add 10 bit rotate methods. This initial implementation is based on current unoptimized code in webrtc using just plain for loops. Bug: libyuv:949 Change-Id: Ic87ee49c3a0b62edbaaa4255c263c1f7be4ea02b Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4110782 Reviewed-by: Frank Barchard Commit-Queue: Frank Barchard --- source/rotate_common.cc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index ff212ade..f24accfb 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -100,6 +100,72 @@ void TransposeUVWxH_C(const uint8_t* src, } } +void TransposeWx8_16_C(const uint16_t* src, + int src_stride, + uint16_t* dst, + int dst_stride, + int width) { + int i; + for (i = 0; i < width; ++i) { + dst[0] = src[0 * src_stride]; + dst[1] = src[1 * src_stride]; + dst[2] = src[2 * src_stride]; + dst[3] = src[3 * src_stride]; + dst[4] = src[4 * src_stride]; + dst[5] = src[5 * src_stride]; + dst[6] = src[6 * src_stride]; + dst[7] = src[7 * src_stride]; + ++src; + dst += dst_stride; + } +} + +void TransposeUVWx8_16_C(const uint16_t* src, + int src_stride, + uint16_t* dst_a, + int dst_stride_a, + uint16_t* dst_b, + int dst_stride_b, + int width) { + int i; + for (i = 0; i < width; ++i) { + dst_a[0] = src[0 * src_stride + 0]; + dst_b[0] = src[0 * src_stride + 1]; + dst_a[1] = src[1 * src_stride + 0]; + dst_b[1] = src[1 * src_stride + 1]; + dst_a[2] = src[2 * src_stride + 0]; + dst_b[2] = src[2 * src_stride + 1]; + dst_a[3] = src[3 * src_stride + 0]; + dst_b[3] = src[3 * src_stride + 1]; + dst_a[4] = src[4 * src_stride + 0]; + dst_b[4] = src[4 * src_stride + 1]; + dst_a[5] = src[5 * src_stride + 0]; + dst_b[5] = src[5 * src_stride + 1]; + dst_a[6] = src[6 * src_stride + 0]; + dst_b[6] = src[6 * src_stride + 1]; + dst_a[7] = src[7 * src_stride + 0]; + dst_b[7] = src[7 * src_stride + 1]; + src += 2; + dst_a += dst_stride_a; + dst_b += dst_stride_b; + } +} + +void TransposeWxH_16_C(const uint16_t* src, + int src_stride, + uint16_t* dst, + int dst_stride, + int width, + int height) { + int i; + for (i = 0; i < width; ++i) { + int j; + for (j = 0; j < height; ++j) { + dst[i * dst_stride + j] = src[j * src_stride + i]; + } + } +} + #ifdef __cplusplus } // extern "C" } // namespace libyuv -- cgit v1.2.3 From 6e4b0acb4b3d5858c77a044aad46132998ac4a76 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 4 Jan 2023 14:27:04 -0800 Subject: I422Rotate take stride for temporary buffers - Minor variable name changes first/last to top/bottom - Comments explaining rotate temporary buffers usage - Add asserts for scale parameter - Use NULL and stddef.h instead of 0 - Use void * for allocation in row.h - Add () around size parameter in macros Bug: libyuv:926, libyuv:949 Change-Id: Ib55417570926ccada0a0f8abd1753dc12e5b162e Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4136762 Reviewed-by: Wan-Teh Chang Commit-Queue: Frank Barchard --- source/rotate_common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index f24accfb..2617c01b 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -94,8 +94,8 @@ void TransposeUVWxH_C(const uint8_t* src, for (i = 0; i < width * 2; i += 2) { int j; for (j = 0; j < height; ++j) { - dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)]; - dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1]; + dst_a[((i >> 1) * dst_stride_a) + j] = src[i + (j * src_stride)]; + dst_b[((i >> 1) * dst_stride_b) + j] = src[i + (j * src_stride) + 1]; } } } -- cgit v1.2.3 From 2bdc210be9eb11ded16bf3ef1f6cadb0d4dcb0c2 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 13 Feb 2023 10:52:58 -0800 Subject: MergeUV_AVX512BW for I420ToNV12 On Skylake Xeon 640x360 100000 iterations AVX512 MergeUVPlane_Opt (1196 ms) AVX2 MergeUVPlane_Opt (1565 ms) SSE2 MergeUVPlane_Opt (1780 ms) Pixel 7 MergeUVPlane_Opt (1177 ms) Bug: None Change-Id: If47d4fa957cf27781bba5fd6a2f0bf554101a5c6 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4242247 Commit-Queue: Frank Barchard Reviewed-by: richard winterton --- source/rotate_common.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index 2617c01b..4b496d1b 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -166,6 +166,63 @@ void TransposeWxH_16_C(const uint16_t* src, } } +// Transpose 32 bit values (ARGB) +void Transpose4x4_32_C(const uint8_t* src, + int src_stride, + uint8_t* dst, + int dst_stride, + int width) { + const uint8_t* src1 = src + src_stride; + const uint8_t* src2 = src1 + src_stride; + const uint8_t* src3 = src2 + src_stride; + uint8_t* dst1 = dst + dst_stride; + uint8_t* dst2 = dst1 + dst_stride; + uint8_t* dst3 = dst2 + dst_stride; + int i; + for (i = 0; i < width; i += 4) { + uint32_t p00 = ((uint32_t*)(src))[0]; + uint32_t p10 = ((uint32_t*)(src))[1]; + uint32_t p20 = ((uint32_t*)(src))[2]; + uint32_t p30 = ((uint32_t*)(src))[3]; + uint32_t p01 = ((uint32_t*)(src1))[0]; + uint32_t p11 = ((uint32_t*)(src1))[1]; + uint32_t p21 = ((uint32_t*)(src1))[2]; + uint32_t p31 = ((uint32_t*)(src1))[3]; + uint32_t p02 = ((uint32_t*)(src2))[0]; + uint32_t p12 = ((uint32_t*)(src2))[1]; + uint32_t p22 = ((uint32_t*)(src2))[2]; + uint32_t p32 = ((uint32_t*)(src2))[3]; + uint32_t p03 = ((uint32_t*)(src3))[0]; + uint32_t p13 = ((uint32_t*)(src3))[1]; + uint32_t p23 = ((uint32_t*)(src3))[2]; + uint32_t p33 = ((uint32_t*)(src3))[3]; + ((uint32_t*)(dst))[0] = p00; + ((uint32_t*)(dst))[1] = p01; + ((uint32_t*)(dst))[2] = p02; + ((uint32_t*)(dst))[3] = p03; + ((uint32_t*)(dst1))[0] = p10; + ((uint32_t*)(dst1))[1] = p11; + ((uint32_t*)(dst1))[2] = p12; + ((uint32_t*)(dst1))[3] = p13; + ((uint32_t*)(dst2))[0] = p20; + ((uint32_t*)(dst2))[1] = p21; + ((uint32_t*)(dst2))[2] = p22; + ((uint32_t*)(dst2))[3] = p23; + ((uint32_t*)(dst3))[0] = p30; + ((uint32_t*)(dst3))[1] = p31; + ((uint32_t*)(dst3))[2] = p32; + ((uint32_t*)(dst3))[3] = p33; + src += src_stride * 4; // advance 4 rows + src1 += src_stride * 4; + src2 += src_stride * 4; + src3 += src_stride * 4; + dst += 4 * 4; // advance 4 columns + dst1 += 4 * 4; + dst2 += 4 * 4; + dst3 += 4 * 4; + } +} + #ifdef __cplusplus } // extern "C" } // namespace libyuv -- cgit v1.2.3 From 650be7496fe171cc0d93935a4c161d45101533f4 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Thu, 29 Jun 2023 22:53:42 -0700 Subject: Fix warnings for missing prototypes - Add static to internal scale and rotate functions - Remove unittest that tested an internal scale function - Remove unused private functions - Include missing scale_argb.h header - Bump version and apply clang format Bug: libyuv:830 Change-Id: I45bab0423b86334f9707f935aedd0c6efc442dd4 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4658956 Reviewed-by: Mirko Bonadei --- source/rotate_common.cc | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'source/rotate_common.cc') diff --git a/source/rotate_common.cc b/source/rotate_common.cc index 4b496d1b..e72608e9 100644 --- a/source/rotate_common.cc +++ b/source/rotate_common.cc @@ -120,37 +120,6 @@ void TransposeWx8_16_C(const uint16_t* src, } } -void TransposeUVWx8_16_C(const uint16_t* src, - int src_stride, - uint16_t* dst_a, - int dst_stride_a, - uint16_t* dst_b, - int dst_stride_b, - int width) { - int i; - for (i = 0; i < width; ++i) { - dst_a[0] = src[0 * src_stride + 0]; - dst_b[0] = src[0 * src_stride + 1]; - dst_a[1] = src[1 * src_stride + 0]; - dst_b[1] = src[1 * src_stride + 1]; - dst_a[2] = src[2 * src_stride + 0]; - dst_b[2] = src[2 * src_stride + 1]; - dst_a[3] = src[3 * src_stride + 0]; - dst_b[3] = src[3 * src_stride + 1]; - dst_a[4] = src[4 * src_stride + 0]; - dst_b[4] = src[4 * src_stride + 1]; - dst_a[5] = src[5 * src_stride + 0]; - dst_b[5] = src[5 * src_stride + 1]; - dst_a[6] = src[6 * src_stride + 0]; - dst_b[6] = src[6 * src_stride + 1]; - dst_a[7] = src[7 * src_stride + 0]; - dst_b[7] = src[7 * src_stride + 1]; - src += 2; - dst_a += dst_stride_a; - dst_b += dst_stride_b; - } -} - void TransposeWxH_16_C(const uint16_t* src, int src_stride, uint16_t* dst, -- cgit v1.2.3