mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-01-01 03:12:16 +08:00
AB64ToARGB fix for inplace conversion
- add tests for all single plane formats that reduce or stay same in size Bug: b/242233673 Change-Id: Ic25d808114f11995ac56ea9c31b99f66ba36d345 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3828485 Reviewed-by: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
parent
9b17af9bef
commit
1c5a8bb17a
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 1838
|
||||
Version: 1839
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1838
|
||||
#define LIBYUV_VERSION 1839
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
@ -439,10 +439,14 @@ void ARGBToAR30Row_C(const uint8_t* src_argb, uint8_t* dst_ar30, int width) {
|
||||
void ARGBToAR64Row_C(const uint8_t* src_argb, uint16_t* dst_ar64, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
dst_ar64[0] = src_argb[0] * 0x0101;
|
||||
dst_ar64[1] = src_argb[1] * 0x0101;
|
||||
dst_ar64[2] = src_argb[2] * 0x0101;
|
||||
dst_ar64[3] = src_argb[3] * 0x0101;
|
||||
uint16_t b = src_argb[0] * 0x0101;
|
||||
uint16_t g = src_argb[1] * 0x0101;
|
||||
uint16_t r = src_argb[2] * 0x0101;
|
||||
uint16_t a = src_argb[3] * 0x0101;
|
||||
dst_ar64[0] = b;
|
||||
dst_ar64[1] = g;
|
||||
dst_ar64[2] = r;
|
||||
dst_ar64[3] = a;
|
||||
dst_ar64 += 4;
|
||||
src_argb += 4;
|
||||
}
|
||||
@ -451,10 +455,14 @@ void ARGBToAR64Row_C(const uint8_t* src_argb, uint16_t* dst_ar64, int width) {
|
||||
void ARGBToAB64Row_C(const uint8_t* src_argb, uint16_t* dst_ab64, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
dst_ab64[0] = src_argb[2] * 0x0101;
|
||||
dst_ab64[1] = src_argb[1] * 0x0101;
|
||||
dst_ab64[2] = src_argb[0] * 0x0101;
|
||||
dst_ab64[3] = src_argb[3] * 0x0101;
|
||||
uint16_t b = src_argb[0] * 0x0101;
|
||||
uint16_t g = src_argb[1] * 0x0101;
|
||||
uint16_t r = src_argb[2] * 0x0101;
|
||||
uint16_t a = src_argb[3] * 0x0101;
|
||||
dst_ab64[0] = r;
|
||||
dst_ab64[1] = g;
|
||||
dst_ab64[2] = b;
|
||||
dst_ab64[3] = a;
|
||||
dst_ab64 += 4;
|
||||
src_argb += 4;
|
||||
}
|
||||
@ -463,10 +471,14 @@ void ARGBToAB64Row_C(const uint8_t* src_argb, uint16_t* dst_ab64, int width) {
|
||||
void AR64ToARGBRow_C(const uint16_t* src_ar64, uint8_t* dst_argb, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
dst_argb[0] = src_ar64[0] >> 8;
|
||||
dst_argb[1] = src_ar64[1] >> 8;
|
||||
dst_argb[2] = src_ar64[2] >> 8;
|
||||
dst_argb[3] = src_ar64[3] >> 8;
|
||||
uint8_t b = src_ar64[0] >> 8;
|
||||
uint8_t g = src_ar64[1] >> 8;
|
||||
uint8_t r = src_ar64[2] >> 8;
|
||||
uint8_t a = src_ar64[3] >> 8;
|
||||
dst_argb[0] = b;
|
||||
dst_argb[1] = g;
|
||||
dst_argb[2] = r;
|
||||
dst_argb[3] = a;
|
||||
dst_argb += 4;
|
||||
src_ar64 += 4;
|
||||
}
|
||||
@ -475,10 +487,14 @@ void AR64ToARGBRow_C(const uint16_t* src_ar64, uint8_t* dst_argb, int width) {
|
||||
void AB64ToARGBRow_C(const uint16_t* src_ab64, uint8_t* dst_argb, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
dst_argb[0] = src_ab64[2] >> 8;
|
||||
dst_argb[1] = src_ab64[1] >> 8;
|
||||
dst_argb[2] = src_ab64[0] >> 8;
|
||||
dst_argb[3] = src_ab64[3] >> 8;
|
||||
uint8_t r = src_ab64[0] >> 8;
|
||||
uint8_t g = src_ab64[1] >> 8;
|
||||
uint8_t b = src_ab64[2] >> 8;
|
||||
uint8_t a = src_ab64[3] >> 8;
|
||||
dst_argb[0] = b;
|
||||
dst_argb[1] = g;
|
||||
dst_argb[2] = r;
|
||||
dst_argb[3] = a;
|
||||
dst_argb += 4;
|
||||
src_ab64 += 4;
|
||||
}
|
||||
|
||||
@ -1410,7 +1410,7 @@ TESTATOBIPLANAR(AYUV, 1, 4, NV21, 2, 2)
|
||||
EPP_B, STRIDE_B, HEIGHT_B)
|
||||
#else
|
||||
#define TESTATOB(FMT_A, TYPE_A, EPP_A, STRIDE_A, HEIGHT_A, FMT_B, TYPE_B, \
|
||||
EPP_B, STRIDE_B, HEIGHT_B) \
|
||||
EPP_B, STRIDE_B, HEIGHT_B, INPLACE) \
|
||||
TESTATOBI(FMT_A, TYPE_A, EPP_A, STRIDE_A, HEIGHT_A, FMT_B, TYPE_B, EPP_B, \
|
||||
STRIDE_B, HEIGHT_B, benchmark_width_, _Opt, +, 0)
|
||||
#endif
|
||||
@ -1450,7 +1450,7 @@ TESTATOB(ARGB, uint8_t, 4, 4, 1, RGB565, uint8_t, 2, 2, 1)
|
||||
#endif
|
||||
TESTATOB(ARGB, uint8_t, 4, 4, 1, RGBA, uint8_t, 4, 4, 1)
|
||||
TESTATOB(ARGB, uint8_t, 4, 4, 1, UYVY, uint8_t, 2, 4, 1)
|
||||
TESTATOB(ARGB, uint8_t, 4, 4, 1, YUY2, uint8_t, 2, 4, 1) // 4
|
||||
TESTATOB(ARGB, uint8_t, 4, 4, 1, YUY2, uint8_t, 2, 4, 1)
|
||||
TESTATOB(ARGB1555, uint8_t, 2, 2, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOB(ARGB4444, uint8_t, 2, 2, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOB(BGRA, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
@ -1484,6 +1484,127 @@ TESTATOB(AB64, uint16_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
TESTATOB(AR64, uint16_t, 4, 4, 1, AB64, uint16_t, 4, 4, 1)
|
||||
TESTATOB(AB64, uint16_t, 4, 4, 1, AR64, uint16_t, 4, 4, 1)
|
||||
|
||||
// in place test
|
||||
#define TESTATOAI(FMT_A, TYPE_A, EPP_A, STRIDE_A, HEIGHT_A, FMT_B, TYPE_B, \
|
||||
EPP_B, STRIDE_B, HEIGHT_B, W1280, N, NEG, OFF) \
|
||||
TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \
|
||||
const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \
|
||||
const int kStrideA = \
|
||||
(kWidth * EPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
|
||||
const int kStrideB = \
|
||||
(kWidth * EPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
|
||||
align_buffer_page_end(src_argb, \
|
||||
kStrideA* kHeightA*(int)sizeof(TYPE_A) + OFF); \
|
||||
align_buffer_page_end(dst_argb_c, \
|
||||
kStrideA* kHeightA*(int)sizeof(TYPE_A) + OFF); \
|
||||
align_buffer_page_end(dst_argb_opt, \
|
||||
kStrideA* kHeightA*(int)sizeof(TYPE_A) + OFF); \
|
||||
for (int i = 0; i < kStrideA * kHeightA * (int)sizeof(TYPE_A); ++i) { \
|
||||
src_argb[i + OFF] = (fastrand() & 0xff); \
|
||||
} \
|
||||
memcpy(dst_argb_c + OFF, src_argb, \
|
||||
kStrideA * kHeightA * (int)sizeof(TYPE_A)); \
|
||||
memcpy(dst_argb_opt + OFF, src_argb, \
|
||||
kStrideA * kHeightA * (int)sizeof(TYPE_A)); \
|
||||
MaskCpuFlags(disable_cpu_flags_); \
|
||||
FMT_A##To##FMT_B((TYPE_A*)(dst_argb_c /* src */ + OFF), kStrideA, \
|
||||
(TYPE_B*)dst_argb_c, kStrideB, kWidth, NEG kHeight); \
|
||||
MaskCpuFlags(benchmark_cpu_info_); \
|
||||
for (int i = 0; i < benchmark_iterations_; ++i) { \
|
||||
FMT_A##To##FMT_B((TYPE_A*)(dst_argb_opt /* src */ + OFF), kStrideA, \
|
||||
(TYPE_B*)dst_argb_opt, kStrideB, kWidth, NEG kHeight); \
|
||||
} \
|
||||
memcpy(dst_argb_opt + OFF, src_argb, \
|
||||
kStrideA * kHeightA * (int)sizeof(TYPE_A)); \
|
||||
FMT_A##To##FMT_B((TYPE_A*)(dst_argb_opt /* src */ + OFF), kStrideA, \
|
||||
(TYPE_B*)dst_argb_opt, kStrideB, kWidth, NEG kHeight); \
|
||||
for (int i = 0; i < kStrideB * kHeightB * (int)sizeof(TYPE_B); ++i) { \
|
||||
EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); \
|
||||
} \
|
||||
free_aligned_buffer_page_end(src_argb); \
|
||||
free_aligned_buffer_page_end(dst_argb_c); \
|
||||
free_aligned_buffer_page_end(dst_argb_opt); \
|
||||
}
|
||||
|
||||
#define TESTATOA(FMT_A, TYPE_A, EPP_A, STRIDE_A, HEIGHT_A, FMT_B, TYPE_B, \
|
||||
EPP_B, STRIDE_B, HEIGHT_B) \
|
||||
TESTATOAI(FMT_A, TYPE_A, EPP_A, STRIDE_A, HEIGHT_A, FMT_B, TYPE_B, EPP_B, \
|
||||
STRIDE_B, HEIGHT_B, benchmark_width_, _Inplace, +, 0)
|
||||
|
||||
TESTATOA(AB30, uint8_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AB30, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
TESTATOA(ABGR, uint8_t, 4, 4, 1, AR30, uint8_t, 4, 4, 1)
|
||||
#endif
|
||||
TESTATOA(ABGR, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
TESTATOA(AR30, uint8_t, 4, 4, 1, AB30, uint8_t, 4, 4, 1)
|
||||
#endif
|
||||
TESTATOA(AR30, uint8_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
TESTATOA(AR30, uint8_t, 4, 4, 1, AR30, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AR30, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
#endif
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, AR30, uint8_t, 4, 4, 1)
|
||||
#endif
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, ARGB1555, uint8_t, 2, 2, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, ARGB4444, uint8_t, 2, 2, 1)
|
||||
// TODO(fbarchard): Support in place for mirror.
|
||||
// TESTATOA(ARGB, uint8_t, 4, 4, 1, ARGBMirror, uint8_t, 4, 4, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, BGRA, uint8_t, 4, 4, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, I400, uint8_t, 1, 1, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, J400, uint8_t, 1, 1, 1)
|
||||
TESTATOA(RGBA, uint8_t, 4, 4, 1, J400, uint8_t, 1, 1, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, RAW, uint8_t, 3, 3, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, RGB24, uint8_t, 3, 3, 1)
|
||||
TESTATOA(ABGR, uint8_t, 4, 4, 1, RAW, uint8_t, 3, 3, 1)
|
||||
TESTATOA(ABGR, uint8_t, 4, 4, 1, RGB24, uint8_t, 3, 3, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, RGB565, uint8_t, 2, 2, 1)
|
||||
#endif
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, RGBA, uint8_t, 4, 4, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, UYVY, uint8_t, 2, 4, 1)
|
||||
TESTATOA(ARGB, uint8_t, 4, 4, 1, YUY2, uint8_t, 2, 4, 1)
|
||||
// TODO(fbarchard): Support in place for conversions that increase bpp.
|
||||
// TESTATOA(ARGB1555, uint8_t, 2, 2, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
// TESTATOA(ARGB4444, uint8_t, 2, 2, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(BGRA, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
// TESTATOA(I400, uint8_t, 1, 1, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(I400, uint8_t, 1, 1, 1, I400, uint8_t, 1, 1, 1)
|
||||
// TESTATOA(I400, uint8_t, 1, 1, 1, I400Mirror, uint8_t, 1, 1, 1)
|
||||
// TESTATOA(J400, uint8_t, 1, 1, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(J400, uint8_t, 1, 1, 1, J400, uint8_t, 1, 1, 1)
|
||||
// TESTATOA(RAW, uint8_t, 3, 3, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
// TESTATOA(RAW, uint8_t, 3, 3, 1, RGBA, uint8_t, 4, 4, 1)
|
||||
TESTATOA(RAW, uint8_t, 3, 3, 1, RGB24, uint8_t, 3, 3, 1)
|
||||
// TESTATOA(RGB24, uint8_t, 3, 3, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(RGB24, uint8_t, 3, 3, 1, J400, uint8_t, 1, 1, 1)
|
||||
// TESTATOA(RGB24, uint8_t, 3, 3, 1, RGB24Mirror, uint8_t, 3, 3, 1)
|
||||
TESTATOA(RAW, uint8_t, 3, 3, 1, J400, uint8_t, 1, 1, 1)
|
||||
#ifdef LITTLE_ENDIAN_ONLY_TEST
|
||||
// TESTATOA(RGB565, uint8_t, 2, 2, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
#endif
|
||||
TESTATOA(RGBA, uint8_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
// TESTATOA(UYVY, uint8_t, 2, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
// TESTATOA(YUY2, uint8_t, 2, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(YUY2, uint8_t, 2, 4, 1, Y, uint8_t, 1, 1, 1)
|
||||
// TESTATOA(ARGB, uint8_t, 4, 4, 1, AR64, uint16_t, 4, 4, 1)
|
||||
// TESTATOA(ARGB, uint8_t, 4, 4, 1, AB64, uint16_t, 4, 4, 1)
|
||||
// TESTATOA(ABGR, uint8_t, 4, 4, 1, AR64, uint16_t, 4, 4, 1)
|
||||
// TESTATOA(ABGR, uint8_t, 4, 4, 1, AB64, uint16_t, 4, 4, 1)
|
||||
TESTATOA(AR64, uint16_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AB64, uint16_t, 4, 4, 1, ARGB, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AR64, uint16_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AB64, uint16_t, 4, 4, 1, ABGR, uint8_t, 4, 4, 1)
|
||||
TESTATOA(AR64, uint16_t, 4, 4, 1, AB64, uint16_t, 4, 4, 1)
|
||||
TESTATOA(AB64, uint16_t, 4, 4, 1, AR64, uint16_t, 4, 4, 1)
|
||||
|
||||
#define TESTATOBDI(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, FMT_B, BPP_B, STRIDE_B, \
|
||||
HEIGHT_B, W1280, N, NEG, OFF) \
|
||||
TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##Dither##N) { \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user