diff options
author | Frank Barchard <fbarchard@google.com> | 2018-01-29 14:27:07 -0800 |
---|---|---|
committer | Frank Barchard <fbarchard@chromium.org> | 2018-01-29 22:31:31 +0000 |
commit | ffec313dbe58c6b97d4943387bda618dccbe4591 (patch) | |
tree | 2ae8234ebbf95b1e3cff08b2faacf724ec4190f1 /source/convert_from_argb.cc | |
parent | ff8ab9baf11c1b579f8a4bfe22779444ca273449 (diff) | |
download | libyuv-ffec313dbe58c6b97d4943387bda618dccbe4591.tar.gz |
ABGRToAR30 used AVX2 with reversed shuffler
vpshufb is used to reverse R and B channels;
Code is otherwise the same as ARGBToAR30.
Bug: libyuv:751
Test: ABGRToAR30 unittest
Change-Id: I30e02925f5c729e4496c5963ba4ba4af16633b3b
Reviewed-on: https://chromium-review.googlesource.com/891807
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Diffstat (limited to 'source/convert_from_argb.cc')
-rw-r--r-- | source/convert_from_argb.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/convert_from_argb.cc b/source/convert_from_argb.cc index 1fc4289a..839bc333 100644 --- a/source/convert_from_argb.cc +++ b/source/convert_from_argb.cc @@ -1217,6 +1217,55 @@ int ARGBToARGB4444(const uint8_t* src_argb, return 0; } +// Convert ABGR To AR30. +LIBYUV_API +int ABGRToAR30(const uint8_t* src_abgr, + int src_stride_abgr, + uint8_t* dst_ar30, + int dst_stride_ar30, + int width, + int height) { + int y; + void (*ABGRToAR30Row)(const uint8_t* src_abgr, uint8_t* dst_rgb, int width) = + ABGRToAR30Row_C; + if (!src_abgr || !dst_ar30 || width <= 0 || height == 0) { + return -1; + } + if (height < 0) { + height = -height; + src_abgr = src_abgr + (height - 1) * src_stride_abgr; + src_stride_abgr = -src_stride_abgr; + } + // Coalesce rows. + if (src_stride_abgr == width * 4 && dst_stride_ar30 == width * 4) { + width *= height; + height = 1; + src_stride_abgr = dst_stride_ar30 = 0; + } +#if defined(HAS_ABGRTOAR30ROW_SSSE3) + if (TestCpuFlag(kCpuHasSSSE3)) { + ABGRToAR30Row = ABGRToAR30Row_Any_SSSE3; + if (IS_ALIGNED(width, 4)) { + ABGRToAR30Row = ABGRToAR30Row_SSSE3; + } + } +#endif +#if defined(HAS_ABGRTOAR30ROW_AVX2) + if (TestCpuFlag(kCpuHasAVX2)) { + ABGRToAR30Row = ABGRToAR30Row_Any_AVX2; + if (IS_ALIGNED(width, 8)) { + ABGRToAR30Row = ABGRToAR30Row_AVX2; + } + } +#endif + for (y = 0; y < height; ++y) { + ABGRToAR30Row(src_abgr, dst_ar30, width); + src_abgr += src_stride_abgr; + dst_ar30 += dst_stride_ar30; + } + return 0; +} + // Convert ARGB To AR30. LIBYUV_API int ARGBToAR30(const uint8_t* src_argb, |