aboutsummaryrefslogtreecommitdiff
path: root/source/planar_functions.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2022-01-31 11:49:55 -0800
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-01-31 20:05:55 +0000
commit804980bbab748fd0e180cd6e7d9292ff49baf704 (patch)
tree79348716636fcffddf9630ce9654ad899cde68d6 /source/planar_functions.cc
parent2c6bfc02d5265c95df69190c785f5d00d13bb444 (diff)
downloadlibyuv-804980bbab748fd0e180cd6e7d9292ff49baf704.tar.gz
DetilePlane and unittest for NEON
Bug: libyuv:915, b/215425056 Change-Id: Iccab1ed3f6d385f02895d44faa94d198ad79d693 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3424820 Reviewed-by: Justin Green <greenjustin@google.com> Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/planar_functions.cc')
-rw-r--r--source/planar_functions.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/planar_functions.cc b/source/planar_functions.cc
index 4147cfbb..d7cb8dc7 100644
--- a/source/planar_functions.cc
+++ b/source/planar_functions.cc
@@ -853,6 +853,53 @@ int NV21ToNV12(const uint8_t* src_y,
return 0;
}
+// Detile a plane of data
+// tile width is 16 and assumed.
+// tile_height is 16 or 32 for MM21.
+// src_stride_y is bytes per row of source ignoring tiling. e.g. 640
+// TODO: More detile row functions.
+
+LIBYUV_API
+void DetilePlane(const uint8_t* src_y,
+ int src_stride_y,
+ uint8_t* dst_y,
+ int dst_stride_y,
+ int width,
+ int height,
+ int tile_height) {
+ const ptrdiff_t src_tile_stride = 16 * tile_height;
+ int y;
+ void (*DetileRow)(const uint8_t* src, ptrdiff_t src_tile_stride, uint8_t* dst,
+ int width) = DetileRow_C;
+ assert(src_stride_y >= 0);
+ assert(tile_height > 0);
+ assert(src_stride_y > 0);
+
+ // Negative height means invert the image.
+ if (height < 0) {
+ height = -height;
+ dst_y = dst_y + (height - 1) * dst_stride_y;
+ dst_stride_y = -dst_stride_y;
+ }
+
+#if defined(HAS_DETILEROW_NEON)
+ if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
+ DetileRow = DetileRow_NEON;
+ }
+#endif
+
+ // Detile plane
+ for (y = 0; y < height; ++y) {
+ DetileRow(src_y, src_tile_stride, dst_y, width);
+ dst_y += dst_stride_y;
+ src_y += 16;
+ // Advance to next row of tiles.
+ if ((y & (tile_height - 1)) == (tile_height - 1)) {
+ src_y = src_y - src_tile_stride + src_stride_y * tile_height;
+ }
+ }
+}
+
// Support function for NV12 etc RGB channels.
// Width and height are plane sizes (typically half pixel width).
LIBYUV_API