mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
Fix for ARGBColorTable x86 assembly. Sav
BUG=51 TEST=TestARGBColorTable Review URL: https://webrtc-codereview.appspot.com/667011 git-svn-id: http://libyuv.googlecode.com/svn/trunk@307 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
452472dfc4
commit
c0d6dee4f3
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 306
|
||||
Version: 307
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 306
|
||||
#define LIBYUV_VERSION 307
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||
|
||||
@ -59,10 +59,11 @@ enum FourCC {
|
||||
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // bgr565.
|
||||
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // abgr1555.
|
||||
FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444.
|
||||
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
|
||||
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
|
||||
FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
|
||||
FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
|
||||
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
|
||||
FOURCC_H264 = FOURCC('H', '2', '6', '4'),
|
||||
// Next four are Bayer RGB formats. The four characters define the order of
|
||||
// the colours in each 2x2 pixel grid, going left-to-right and top-to-bottom.
|
||||
FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
|
||||
@ -112,10 +113,11 @@ enum FourCCBpp {
|
||||
FOURCC_BPP_RGBP = 16,
|
||||
FOURCC_BPP_RGBO = 16,
|
||||
FOURCC_BPP_R444 = 16,
|
||||
FOURCC_BPP_MJPG = 0, // 0 means unknown.
|
||||
FOURCC_BPP_RAW = 24,
|
||||
FOURCC_BPP_NV21 = 12,
|
||||
FOURCC_BPP_NV12 = 12,
|
||||
FOURCC_BPP_MJPG = 0, // 0 means unknown.
|
||||
FOURCC_BPP_H264 = 0,
|
||||
// Next four are Bayer RGB formats. The four characters define the order of
|
||||
// the colours in each 2x2 pixel grid, going left-to-right and top-to-bottom.
|
||||
FOURCC_BPP_RGGB = 8,
|
||||
|
||||
@ -86,7 +86,7 @@ extern "C" {
|
||||
// The following are Windows only:
|
||||
#if !defined(YUV_DISABLE_ASM) && defined(_M_IX86)
|
||||
// TODO(fbarchard): Investigate possible issue in this function and reenable.
|
||||
#define HAS_ARGBCOLORTABLEROW_X86_DISABLED
|
||||
#define HAS_ARGBCOLORTABLEROW_X86
|
||||
#endif
|
||||
|
||||
// The following are disabled when SSSE3 is available:
|
||||
|
||||
@ -3031,11 +3031,12 @@ void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb,
|
||||
int width) {
|
||||
__asm {
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
push ebp
|
||||
mov eax, [esp + 12 + 4] /* dst_argb */
|
||||
mov edi, [esp + 12 + 8] /* table_argb */
|
||||
mov ecx, [esp + 12 + 12] /* width */
|
||||
mov eax, [esp + 16 + 4] /* dst_argb */
|
||||
mov edi, [esp + 16 + 8] /* table_argb */
|
||||
mov ecx, [esp + 16 + 12] /* width */
|
||||
xor ebx, ebx
|
||||
xor edx, edx
|
||||
|
||||
@ -3064,6 +3065,7 @@ void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb,
|
||||
jg convertloop
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
}
|
||||
|
||||
@ -46,18 +46,18 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##_OptVsC) { \
|
||||
} \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
FMT_PLANAR##To##FMT_B(src_y, kWidth, \
|
||||
src_u, kWidth / SUBSAMP_X, \
|
||||
src_v, kWidth / SUBSAMP_X, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
src_u, kWidth / SUBSAMP_X, \
|
||||
src_v, kWidth / SUBSAMP_X, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
MaskCpuFlags(-1); \
|
||||
const int runs = 1000; \
|
||||
for (int i = 0; i < runs; ++i) { \
|
||||
FMT_PLANAR##To##FMT_B(src_y, kWidth, \
|
||||
src_u, kWidth / SUBSAMP_X, \
|
||||
src_v, kWidth / SUBSAMP_X, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
src_u, kWidth / SUBSAMP_X, \
|
||||
src_v, kWidth / SUBSAMP_X, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
} \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < kHeight; ++i) { \
|
||||
@ -108,16 +108,16 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##_OptVsC) { \
|
||||
} \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
FMT_PLANAR##To##FMT_B(src_y, kWidth, \
|
||||
src_uv, kWidth / SUBSAMP_X * 2, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
src_uv, kWidth / SUBSAMP_X * 2, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
MaskCpuFlags(-1); \
|
||||
const int runs = 1000; \
|
||||
for (int i = 0; i < runs; ++i) { \
|
||||
FMT_PLANAR##To##FMT_B(src_y, kWidth, \
|
||||
src_uv, kWidth / SUBSAMP_X * 2, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
src_uv, kWidth / SUBSAMP_X * 2, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
} \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < kHeight; ++i) { \
|
||||
@ -158,18 +158,18 @@ TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##_OptVsC) { \
|
||||
src_argb[(i * kWidth * BPP_A) + j] = (random() & 0xff); \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
FMT_A##To##FMT_PLANAR(src_argb, kWidth * BPP_A, \
|
||||
dst_y_c, kWidth, \
|
||||
dst_u_c, kWidth / SUBSAMP_X, \
|
||||
dst_v_c, kWidth / SUBSAMP_X, \
|
||||
kWidth, kHeight); \
|
||||
dst_y_c, kWidth, \
|
||||
dst_u_c, kWidth / SUBSAMP_X, \
|
||||
dst_v_c, kWidth / SUBSAMP_X, \
|
||||
kWidth, kHeight); \
|
||||
MaskCpuFlags(-1); \
|
||||
const int runs = 1000; \
|
||||
for (int i = 0; i < runs; ++i) { \
|
||||
FMT_A##To##FMT_PLANAR(src_argb, kWidth * BPP_A, \
|
||||
dst_y_opt, kWidth, \
|
||||
dst_u_opt, kWidth / SUBSAMP_X, \
|
||||
dst_v_opt, kWidth / SUBSAMP_X, \
|
||||
kWidth, kHeight); \
|
||||
dst_y_opt, kWidth, \
|
||||
dst_u_opt, kWidth / SUBSAMP_X, \
|
||||
dst_v_opt, kWidth / SUBSAMP_X, \
|
||||
kWidth, kHeight); \
|
||||
} \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < kHeight; ++i) { \
|
||||
@ -237,14 +237,14 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##_OptVsC) { \
|
||||
} \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
MaskCpuFlags(-1); \
|
||||
const int runs = 1000; \
|
||||
for (int i = 0; i < runs; ++i) { \
|
||||
FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
} \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < kHeight * kWidth * BPP_B; ++i) { \
|
||||
@ -294,12 +294,12 @@ TEST_F(libyuvTest, FMT_A##To##FMT_B##_Random) { \
|
||||
} \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
dst_argb_c, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
MaskCpuFlags(-1); \
|
||||
FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
dst_argb_opt, kWidth * BPP_B, \
|
||||
kWidth, kHeight); \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < kHeight * kWidth * BPP_B; ++i) { \
|
||||
int diff = static_cast<int>(dst_argb_c[i]) - \
|
||||
@ -601,6 +601,65 @@ TEST_F(libyuvTest, TestARGBColorMatrix) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_F(libyuvTest, TestARGBColorTable) {
|
||||
SIMD_ALIGNED(uint8 orig_pixels[256][4]);
|
||||
|
||||
// Matrix for Sepia.
|
||||
static const uint8 kARGBTable[256 * 4] = {
|
||||
1u, 2u, 3u, 4u,
|
||||
5u, 6u, 7u, 8u,
|
||||
9u, 10u, 11u, 12u,
|
||||
13u, 14u, 15u, 16u,
|
||||
};
|
||||
|
||||
orig_pixels[0][0] = 0u;
|
||||
orig_pixels[0][1] = 0u;
|
||||
orig_pixels[0][2] = 0u;
|
||||
orig_pixels[0][3] = 0u;
|
||||
orig_pixels[1][0] = 1u;
|
||||
orig_pixels[1][1] = 1u;
|
||||
orig_pixels[1][2] = 1u;
|
||||
orig_pixels[1][3] = 1u;
|
||||
orig_pixels[2][0] = 2u;
|
||||
orig_pixels[2][1] = 2u;
|
||||
orig_pixels[2][2] = 2u;
|
||||
orig_pixels[2][3] = 2u;
|
||||
orig_pixels[3][0] = 0u;
|
||||
orig_pixels[3][1] = 1u;
|
||||
orig_pixels[3][2] = 2u;
|
||||
orig_pixels[3][3] = 3u;
|
||||
// Do 16 to test asm version.
|
||||
ARGBColorTable(&orig_pixels[0][0], 0, &kARGBTable[0], 0, 0, 16, 1);
|
||||
EXPECT_EQ(1u, orig_pixels[0][0]);
|
||||
EXPECT_EQ(2u, orig_pixels[0][1]);
|
||||
EXPECT_EQ(3u, orig_pixels[0][2]);
|
||||
EXPECT_EQ(4u, orig_pixels[0][3]);
|
||||
EXPECT_EQ(5u, orig_pixels[1][0]);
|
||||
EXPECT_EQ(6u, orig_pixels[1][1]);
|
||||
EXPECT_EQ(7u, orig_pixels[1][2]);
|
||||
EXPECT_EQ(8u, orig_pixels[1][3]);
|
||||
EXPECT_EQ(9u, orig_pixels[2][0]);
|
||||
EXPECT_EQ(10u, orig_pixels[2][1]);
|
||||
EXPECT_EQ(11u, orig_pixels[2][2]);
|
||||
EXPECT_EQ(12u, orig_pixels[2][3]);
|
||||
EXPECT_EQ(1u, orig_pixels[3][0]);
|
||||
EXPECT_EQ(6u, orig_pixels[3][1]);
|
||||
EXPECT_EQ(11u, orig_pixels[3][2]);
|
||||
EXPECT_EQ(16u, orig_pixels[3][3]);
|
||||
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
orig_pixels[i][0] = i;
|
||||
orig_pixels[i][1] = i / 2;
|
||||
orig_pixels[i][2] = i / 3;
|
||||
orig_pixels[i][3] = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) {
|
||||
ARGBColorTable(&orig_pixels[0][0], 0, &kARGBTable[0], 0, 0, 256, 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(libyuvTest, TestARGBQuantize) {
|
||||
SIMD_ALIGNED(uint8 orig_pixels[256][4]);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user