From 9c9215b2187f16ddfc38312c994ffa881e7b50f9 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Thu, 15 Feb 2018 15:14:50 -0800 Subject: [PATCH] End swap 10 bit RGB Bug: libyuv:777 Test: None Change-Id: I69b81f51c50d7739cfdb3cfb0c3d315c32bd63d2 Reviewed-on: https://chromium-review.googlesource.com/923042 Reviewed-by: Miguel Casas Commit-Queue: Frank Barchard --- README.chromium | 2 +- include/libyuv/convert_argb.h | 16 +++++++++++++++- include/libyuv/row.h | 3 +++ include/libyuv/version.h | 2 +- source/convert_argb.cc | 32 ++++++++++++++++++++++++++++++++ source/row_common.cc | 14 ++++++++++++++ unit_test/convert_test.cc | 4 +++- 7 files changed, 69 insertions(+), 4 deletions(-) diff --git a/README.chromium b/README.chromium index f38414b3a..8d352c223 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1698 +Version: 1699 License: BSD License File: LICENSE diff --git a/include/libyuv/convert_argb.h b/include/libyuv/convert_argb.h index cd4a611de..4100170ae 100644 --- a/include/libyuv/convert_argb.h +++ b/include/libyuv/convert_argb.h @@ -547,6 +547,12 @@ int ARGB4444ToARGB(const uint8_t* src_argb4444, int width, int height); + +// Aliases +#define AB30ToARGB AR30ToABGR +#define AB30ToABGR AR30ToARGB +#define AB30ToAR30 AR30ToAB30 + // Convert AR30 To ARGB. LIBYUV_API int AR30ToARGB(const uint8_t* src_ar30, @@ -556,7 +562,6 @@ int AR30ToARGB(const uint8_t* src_ar30, int width, int height); -#define AB30ToABGR // Convert AR30 To ABGR. LIBYUV_API @@ -567,6 +572,15 @@ int AR30ToABGR(const uint8_t* src_ar30, int width, int height); +// Convert AR30 To AB30. +LIBYUV_API +int AR30ToAB30(const uint8_t* src_ar30, + int src_stride_ar30, + uint8_t* dst_ab30, + int dst_stride_ab30, + int width, + int height); + #ifdef HAVE_JPEG // src_width/height provided by capture // dst_width/height for clipping determine final size. diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 62ed119db..f5cb441e1 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -1612,6 +1612,9 @@ void ARGB4444ToARGBRow_C(const uint8_t* src_argb4444, int width); void AR30ToARGBRow_C(const uint8_t* src_ar30, uint8_t* dst_argb, int width); void AR30ToABGRRow_C(const uint8_t* src_ar30, uint8_t* dst_abgr, int width); +void ARGBToAR30Row_C(const uint8_t* src_argb, uint8_t* dst_ar30, int width); +void AR30ToAB30Row_C(const uint8_t* src_ar30, uint8_t* dst_ab30, int width); + void RGB24ToARGBRow_Any_SSSE3(const uint8_t* src_ptr, uint8_t* dst_ptr, int width); diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 683ac0482..aef9438b1 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1698 +#define LIBYUV_VERSION 1699 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/convert_argb.cc b/source/convert_argb.cc index e084f6806..ff91602e4 100644 --- a/source/convert_argb.cc +++ b/source/convert_argb.cc @@ -1534,6 +1534,38 @@ int AR30ToABGR(const uint8_t* src_ar30, return 0; } +// Convert AR30 to AB30. +LIBYUV_API +int AR30ToAB30(const uint8_t* src_ar30, + int src_stride_ar30, + uint8_t* dst_ab30, + int dst_stride_ab30, + int width, + int height) { + int y; + if (!src_ar30 || !dst_ab30 || width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. + if (height < 0) { + height = -height; + src_ar30 = src_ar30 + (height - 1) * src_stride_ar30; + src_stride_ar30 = -src_stride_ar30; + } + // Coalesce rows. + if (src_stride_ar30 == width * 4 && dst_stride_ab30 == width * 4) { + width *= height; + height = 1; + src_stride_ar30 = dst_stride_ab30 = 0; + } + for (y = 0; y < height; ++y) { + AR30ToAB30Row_C(src_ar30, dst_ab30, width); + src_ar30 += src_stride_ar30; + dst_ab30 += dst_stride_ab30; + } + return 0; +} + // Convert NV12 to ARGB with matrix static int NV12ToARGBMatrix(const uint8_t* src_y, int src_stride_y, diff --git a/source/row_common.cc b/source/row_common.cc index 297d87e01..625405af8 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -212,6 +212,20 @@ void AR30ToABGRRow_C(const uint8_t* src_ar30, uint8_t* dst_abgr, int width) { } } +void AR30ToAB30Row_C(const uint8_t* src_ar30, uint8_t* dst_ab30, int width) { + int x; + for (x = 0; x < width; ++x) { + uint32_t ar30 = *(uint32_t*)src_ar30; + uint32_t b = ar30 & 0x3ff; + uint32_t g = (ar30 >> 10) & 0x3ff; + uint32_t r = (ar30 >> 20) & 0x3ff; + uint32_t a = (ar30 >> 30) & 0x3; + *(uint32_t*)(dst_ab30) = r | (g << 10) | (b << 20) | (a << 30); + dst_ab30 += 4; + src_ar30 += 4; + } +} + void ARGBToRGB24Row_C(const uint8_t* src_argb, uint8_t* dst_rgb, int width) { int x; for (x = 0; x < width; ++x) { diff --git a/unit_test/convert_test.cc b/unit_test/convert_test.cc index 750bd8719..b65db278d 100644 --- a/unit_test/convert_test.cc +++ b/unit_test/convert_test.cc @@ -596,7 +596,6 @@ TESTPLANARTOB(I420, 2, 2, I400, 1, 1, 1, 0, ARGB, 4) TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) TESTPLANARTOB(I420, 2, 2, AR30, 4, 4, 1, 0, ARGB, 4) TESTPLANARTOB(H420, 2, 2, AR30, 4, 4, 1, 0, ARGB, 4) -// TESTPLANARTOB(I420, 2, 2, AR30, 4, 4, 1, 0, ABGR, 4) #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \ @@ -1084,6 +1083,9 @@ TESTATOB(ARGB1555, 2, 2, 1, ARGB, 4, 4, 1, 0) TESTATOB(ARGB4444, 2, 2, 1, ARGB, 4, 4, 1, 0) TESTATOB(AR30, 4, 4, 1, ARGB, 4, 4, 1, 0) TESTATOB(AR30, 4, 4, 1, ABGR, 4, 4, 1, 0) +TESTATOB(AB30, 4, 4, 1, ARGB, 4, 4, 1, 0) +TESTATOB(AB30, 4, 4, 1, ABGR, 4, 4, 1, 0) +TESTATOB(AR30, 4, 4, 1, AB30, 4, 4, 1, 0) TESTATOB(YUY2, 2, 4, 1, ARGB, 4, 4, 1, ARM_YUV_ERROR) TESTATOB(UYVY, 2, 4, 1, ARGB, 4, 4, 1, ARM_YUV_ERROR) TESTATOB(YUY2, 2, 4, 1, Y, 1, 1, 1, 0)