aboutsummaryrefslogtreecommitdiff
path: root/source/convert_argb.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2019-10-14 13:41:17 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-14 22:27:37 +0000
commit22f8aad8bc4fca1ad64f72e6a75d58783a0c5035 (patch)
tree9cce7377f91189b18acd0a6c63c77601ed0697f4 /source/convert_argb.cc
parent98a4882de5b949d4f7f344718af5da5ff18bc0b5 (diff)
downloadlibyuv-22f8aad8bc4fca1ad64f72e6a75d58783a0c5035.tar.gz
RAWToRGBA for 3 channel OCR
Replace ARM64 only row function with high level function that implements SSSE3, 32 bit Neon and C. Compared to 2 step RAWToARGB + ARGBToRGBA on row level: 3.1x faster on ARM 6.2% faster on Intel BUG=b/140748379 Change-Id: Ia8636d9e4fcdbe10b8c2e81610a54728e29845cd Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/1860914 Reviewed-by: richard winterton <rrwinterton@gmail.com> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/convert_argb.cc')
-rw-r--r--source/convert_argb.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/convert_argb.cc b/source/convert_argb.cc
index 38011d11..f46b4309 100644
--- a/source/convert_argb.cc
+++ b/source/convert_argb.cc
@@ -1349,6 +1349,57 @@ int RAWToARGB(const uint8_t* src_raw,
return 0;
}
+// Convert RAW to RGBA.
+LIBYUV_API
+int RAWToRGBA(const uint8_t* src_raw,
+ int src_stride_raw,
+ uint8_t* dst_rgba,
+ int dst_stride_rgba,
+ int width,
+ int height) {
+ int y;
+ void (*RAWToRGBARow)(const uint8_t* src_rgb, uint8_t* dst_rgba, int width) =
+ RAWToRGBARow_C;
+ if (!src_raw || !dst_rgba || width <= 0 || height == 0) {
+ return -1;
+ }
+ // Negative height means invert the image.
+ if (height < 0) {
+ height = -height;
+ src_raw = src_raw + (height - 1) * src_stride_raw;
+ src_stride_raw = -src_stride_raw;
+ }
+ // Coalesce rows.
+ if (src_stride_raw == width * 3 && dst_stride_rgba == width * 4) {
+ width *= height;
+ height = 1;
+ src_stride_raw = dst_stride_rgba = 0;
+ }
+#if defined(HAS_RAWTORGBAROW_SSSE3)
+ if (TestCpuFlag(kCpuHasSSSE3)) {
+ RAWToRGBARow = RAWToRGBARow_Any_SSSE3;
+ if (IS_ALIGNED(width, 16)) {
+ RAWToRGBARow = RAWToRGBARow_SSSE3;
+ }
+ }
+#endif
+#if defined(HAS_RAWTORGBAROW_NEON)
+ if (TestCpuFlag(kCpuHasNEON)) {
+ RAWToRGBARow = RAWToRGBARow_Any_NEON;
+ if (IS_ALIGNED(width, 8)) {
+ RAWToRGBARow = RAWToRGBARow_NEON;
+ }
+ }
+#endif
+
+ for (y = 0; y < height; ++y) {
+ RAWToRGBARow(src_raw, dst_rgba, width);
+ src_raw += src_stride_raw;
+ dst_rgba += dst_stride_rgba;
+ }
+ return 0;
+}
+
// Convert RGB565 to ARGB.
LIBYUV_API
int RGB565ToARGB(const uint8_t* src_rgb565,