Commit 81b804e3 authored by fbarchard@google.com's avatar fbarchard@google.com

ARGBQuantize to do a posterizing effect. Added random resolution unittest.

BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/654005

git-svn-id: http://libyuv.googlecode.com/svn/trunk@289 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent e442dc4c
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 288
Version: 289
License: BSD
License File: LICENSE
......
......@@ -216,8 +216,11 @@ int ARGBGray(uint8* dst_argb, int dst_stride_argb,
int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
int x, int y, int width, int height);
// Apply a 4x3 matrix rotation to each ARGB pixel.
// Apply a matrix rotation to each ARGB pixel.
// matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1.
// The first 4 coefficients apply to B, G, R, A and produce B of the output.
// The next 4 coefficients apply to B, G, R, A and produce G of the output.
// The last 4 coefficients apply to B, G, R, A and produce R of the output.
int ARGBColorMatrix(uint8* dst_argb, int dst_stride_argb,
const int8* matrix_argb,
int x, int y, int width, int height);
......@@ -228,6 +231,14 @@ int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
const uint8* table_argb,
int x, int y, int width, int height);
// Quantize a rectangle of ARGB. Alpha unaffected.
// scale is a 16 bit fractional fixed point scaler between 0 and 65535.
// interval_size should be a value between 1 and 255.
// interval_offset should be a value between 0 and 255.
int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
int scale, int interval_size, int interval_offset,
int x, int y, int width, int height);
// Copy ARGB to ARGB.
int ARGBCopy(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
......
......@@ -11,7 +11,7 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 288
#define LIBYUV_VERSION 289
#endif // INCLUDE_LIBYUV_VERSION_H_
......@@ -1448,8 +1448,7 @@ int ARGBGray(uint8* dst_argb, int dst_stride_argb,
// Make a rectangle of ARGB Sepia tone.
int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
int dst_x, int dst_y,
int width, int height) {
int dst_x, int dst_y, int width, int height) {
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
......@@ -1513,6 +1512,37 @@ int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
}
return 0;
}
// ARGBQuantize is used to posterize art.
// e.g. rgb / qvalue * qvalue + qvalue / 2
// But the low levels implement efficiently with 3 parameters, and could be
// used for other high level operations.
// The divide is replaces with a multiply by reciprocal fixed point multiply.
// Caveat - although SSE2 saturates, the C function does not and should be used
// with care if doing anything but quantization.
int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
int scale, int interval_size, int interval_offset,
int dst_x, int dst_y, int width, int height) {
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0 ||
interval_size < 1 || interval_size > 255) {
return -1;
}
void (*ARGBQuantizeRow)(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width) = ARGBQuantizeRow_C;
#if defined(HAS_ARGBQUANTIZEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
ARGBQuantizeRow = ARGBQuantizeRow_SSE2;
}
#endif
uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
for (int y = 0; y < height; ++y) {
ARGBQuantizeRow(dst, scale, interval_size, interval_offset, width);
dst += dst_stride_argb;
}
return 0;
}
#ifdef HAVE_JPEG
struct ARGBBuffers {
uint8* argb;
......
......@@ -76,6 +76,7 @@ extern "C" {
#define HAS_ARGBGRAYROW_SSSE3
#define HAS_ARGBSEPIAROW_SSSE3
#define HAS_ARGBCOLORMATRIXROW_SSSE3
#define HAS_ARGBQUANTIZEROW_SSE2
#define HAS_COMPUTECUMULATIVESUMROW_SSE2
#define HAS_CUMULATIVESUMTOAVERAGE_SSE2
#endif
......@@ -85,7 +86,6 @@ extern "C" {
#define HAS_ARGBCOLORTABLEROW_X86
#endif
// The following are disabled when SSSE3 is available:
#if !defined(YUV_DISABLE_ASM) && \
(defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) && \
......@@ -494,8 +494,12 @@ void ARGBColorMatrixRow_SSSE3(uint8* dst_argb, const int8* matrix_argb,
int width);
void ARGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width);
void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb,
int width);
void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb, int width);
void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width);
void ARGBQuantizeRow_SSE2(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width);
// Used for blur.
void CumulativeSumToAverage_SSE2(const int32* topleft, const int32* botleft,
......
......@@ -363,6 +363,19 @@ void ARGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width) {
}
}
void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width) {
for (int x = 0; x < width; ++x) {
int b = dst_argb[0];
int g = dst_argb[1];
int r = dst_argb[2];
dst_argb[0] = (b * scale >> 16) * interval_size + interval_offset;
dst_argb[1] = (g * scale >> 16) * interval_size + interval_offset;
dst_argb[2] = (r * scale >> 16) * interval_size + interval_offset;
dst_argb += 4;
}
}
void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) {
// Copy a Y to RGB.
for (int x = 0; x < width; ++x) {
......
......@@ -2589,7 +2589,7 @@ void ARGBAttenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width) {
"pcmpeqb %%xmm5,%%xmm5 \n"
"psrld $0x8,%%xmm5 \n"
// 4 pixel loop
// 4 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2644,7 +2644,7 @@ void ARGBAttenuateRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width) {
"movdqa %3,%%xmm4 \n"
"movdqa %4,%%xmm5 \n"
// 4 pixel loop
// 4 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2691,7 +2691,7 @@ void ARGBUnattenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb,
"pcmpeqb %%xmm4,%%xmm4 \n"
"pslld $0x18,%%xmm4 \n"
// 4 pixel loop
// 4 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2745,7 +2745,8 @@ CONST vec8 kARGBToGray = {
void ARGBGrayRow_SSSE3(uint8* dst_argb, int width) {
asm volatile (
"movdqa %2,%%xmm4 \n"
// 8 pixel loop \n"
// 8 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2806,7 +2807,8 @@ void ARGBSepiaRow_SSSE3(uint8* dst_argb, int width) {
"movdqa %2,%%xmm2 \n"
"movdqa %3,%%xmm3 \n"
"movdqa %4,%%xmm4 \n"
// 8 pixel loop \n"
// 8 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2871,7 +2873,8 @@ void ARGBColorMatrixRow_SSSE3(uint8* dst_argb, const int8* matrix_argb,
"pshufd $0x0,%%xmm2,%%xmm2 \n"
"pshufd $0x0,%%xmm3,%%xmm3 \n"
"pshufd $0x0,%%xmm4,%%xmm4 \n"
// 8 pixel loop \n"
// 8 pixel loop.
".p2align 4 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
......@@ -2922,6 +2925,59 @@ void ARGBColorMatrixRow_SSSE3(uint8* dst_argb, const int8* matrix_argb,
}
#endif // HAS_ARGBCOLORMATRIXROW_SSSE3
#ifdef HAS_ARGBQUANTIZEROW_SSE2
// Quantize 4 ARGB pixels (16 bytes).
// aligned to 16 bytes
void ARGBQuantizeRow_SSE2(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width) {
asm volatile (
"movd %2,%%xmm2 \n"
"movd %3,%%xmm3 \n"
"movd %4,%%xmm4 \n"
"pshuflw $0x40,%%xmm2,%%xmm2 \n"
"pshufd $0x44,%%xmm2,%%xmm2 \n"
"pshuflw $0x40,%%xmm3,%%xmm3 \n"
"pshufd $0x44,%%xmm3,%%xmm3 \n"
"pshuflw $0x40,%%xmm4,%%xmm4 \n"
"pshufd $0x44,%%xmm4,%%xmm4 \n"
"pxor %%xmm5,%%xmm5 \n"
"pcmpeqb %%xmm6,%%xmm6 \n"
"pslld $0x18,%%xmm6 \n"
// 4 pixel loop.
".p2align 2 \n"
"1: \n"
"movdqa (%0),%%xmm0 \n"
"punpcklbw %%xmm5,%%xmm0 \n"
"pmulhuw %%xmm2,%%xmm0 \n"
"movdqa (%0),%%xmm1 \n"
"punpckhbw %%xmm5,%%xmm1 \n"
"pmulhuw %%xmm2,%%xmm1 \n"
"pmullw %%xmm3,%%xmm0 \n"
"movdqa (%0),%%xmm7 \n"
"pmullw %%xmm3,%%xmm1 \n"
"pand %%xmm6,%%xmm7 \n"
"paddw %%xmm4,%%xmm0 \n"
"paddw %%xmm4,%%xmm1 \n"
"packuswb %%xmm1,%%xmm0 \n"
"por %%xmm7,%%xmm0 \n"
"sub $0x4,%1 \n"
"movdqa %%xmm0,(%0) \n"
"lea 0x10(%0),%0 \n"
"jg 1b \n"
: "+r"(dst_argb), // %0
"+r"(width) // %1
: "r"(scale), // %2
"r"(interval_size), // %3
"r"(interval_offset) // %4
: "memory", "cc"
#if defined(__SSE2__)
, "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
#endif
);
}
#endif // HAS_ARGBQUANTIZEROW_SSE2
#ifdef HAS_COMPUTECUMULATIVESUMROW_SSE2
// Creates a table of cumulative sums where each value is a sum of all values
// above and to the left of the value, inclusive of the value.
......
......@@ -2930,6 +2930,7 @@ void ARGBSepiaRow_SSSE3(uint8* dst_argb, int width) {
}
}
#endif // HAS_ARGBSEPIAROW_SSSE3
#ifdef HAS_ARGBCOLORMATRIXROW_SSSE3
// Tranform 8 ARGB pixels (32 bytes) with color matrix.
// Same as Sepia except matrix is provided.
......@@ -3042,6 +3043,53 @@ void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb,
}
#endif // HAS_ARGBCOLORTABLEROW_X86
#ifdef HAS_ARGBQUANTIZEROW_SSE2
// Quantize 4 ARGB pixels (16 bytes).
// aligned to 16 bytes
__declspec(naked) __declspec(align(16))
void ARGBQuantizeRow_SSE2(uint8* dst_argb, int scale, int interval_size,
int interval_offset, int width) {
__asm {
mov eax, [esp + 4] /* dst_argb */
movd xmm2, [esp + 8] /* scale */
movd xmm3, [esp + 12] /* interval_size */
movd xmm4, [esp + 16] /* interval_offset */
mov ecx, [esp + 20] /* width */
pshuflw xmm2, xmm2, 040h
pshufd xmm2, xmm2, 044h
pshuflw xmm3, xmm3, 040h
pshufd xmm3, xmm3, 044h
pshuflw xmm4, xmm4, 040h
pshufd xmm4, xmm4, 044h
pxor xmm5, xmm5 // constant 0
pcmpeqb xmm6, xmm6 // generate mask 0xff000000
pslld xmm6, 24
align 16
convertloop:
movdqa xmm0, [eax] // read 4 pixels
punpcklbw xmm0, xmm5 // first 2 pixels
pmulhuw xmm0, xmm2 // pixel * scale >> 16
movdqa xmm1, [eax] // read 4 pixels
punpckhbw xmm1, xmm5 // next 2 pixels
pmulhuw xmm1, xmm2
pmullw xmm0, xmm3 // * interval_size
movdqa xmm7, [eax] // read 4 pixels
pmullw xmm1, xmm3
pand xmm7, xmm6 // mask alpha
paddw xmm0, xmm4 // + interval_size / 2
paddw xmm1, xmm4
packuswb xmm0, xmm1
por xmm0, xmm7
sub ecx, 4
movdqa [eax], xmm0
lea eax, [eax + 16]
jg convertloop
ret
}
}
#endif // HAS_ARGBQUANTIZEROW_SSE2
#ifdef HAS_CUMULATIVESUMTOAVERAGE_SSE2
// Consider float CumulativeSum.
// Consider calling CumulativeSum one row at time as needed.
......
......@@ -32,8 +32,8 @@ static uint32 ReferenceHashDjb2(const uint8* src, uint64 count, uint32 seed) {
TEST_F(libyuvTest, TestDjb2) {
const int kMaxTest = 2049;
align_buffer_16(src_a, kMaxTest)
for (int i = 0; i < kMaxTest; ++i) {
src_a[i] = i;
}
......@@ -55,8 +55,8 @@ TEST_F(libyuvTest, TestDjb2) {
TEST_F(libyuvTest, BenchmakDjb2_C) {
const int kMaxTest = 1280 * 720;
align_buffer_16(src_a, kMaxTest)
for (int i = 0; i < kMaxTest; ++i) {
src_a[i] = i;
}
......@@ -73,8 +73,8 @@ TEST_F(libyuvTest, BenchmakDjb2_C) {
TEST_F(libyuvTest, BenchmakDjb2_OPT) {
const int kMaxTest = 1280 * 720;
align_buffer_16(src_a, kMaxTest)
for (int i = 0; i < kMaxTest; ++i) {
src_a[i] = i;
}
......@@ -89,8 +89,8 @@ TEST_F(libyuvTest, BenchmakDjb2_OPT) {
TEST_F(libyuvTest, BenchmakDjb2_Unaligned_OPT) {
const int kMaxTest = 1280 * 720;
align_buffer_16(src_a, kMaxTest + 1)
for (int i = 0; i < kMaxTest; ++i) {
src_a[i + 1] = i;
}
......@@ -104,14 +104,18 @@ TEST_F(libyuvTest, BenchmakDjb2_Unaligned_OPT) {
}
TEST_F(libyuvTest, BenchmarkSumSquareError_C) {
const int max_width = 4096*3;
const int kMaxWidth = 4096 * 3;
align_buffer_16(src_a, kMaxWidth)
align_buffer_16(src_b, kMaxWidth)
align_buffer_16(src_a, max_width)
align_buffer_16(src_b, max_width)
for (int i = 0; i < kMaxWidth; ++i) {
src_a[i] = i;
src_b[i] = i;
}
MaskCpuFlags(kCpuInitialized);
for (int i = 0; i < benchmark_iterations_; ++i) {
ComputeSumSquareError(src_a, src_b, max_width);
ComputeSumSquareError(src_a, src_b, kMaxWidth);
}
MaskCpuFlags(-1);
......@@ -123,13 +127,17 @@ TEST_F(libyuvTest, BenchmarkSumSquareError_C) {
}
TEST_F(libyuvTest, BenchmarkSumSquareError_OPT) {
const int max_width = 4096*3;
const int kMaxWidth = 4096 * 3;
align_buffer_16(src_a, kMaxWidth)
align_buffer_16(src_b, kMaxWidth)
align_buffer_16(src_a, max_width)
align_buffer_16(src_b, max_width)
for (int i = 0; i < kMaxWidth; ++i) {
src_a[i] = i;
src_b[i] = i;
}
for (int i = 0; i < benchmark_iterations_; ++i) {
ComputeSumSquareError(src_a, src_b, max_width);
ComputeSumSquareError(src_a, src_b, kMaxWidth);
}
EXPECT_EQ(0, 0);
......@@ -139,42 +147,41 @@ TEST_F(libyuvTest, BenchmarkSumSquareError_OPT) {
}
TEST_F(libyuvTest, SumSquareError) {
const int max_width = 4096*3;
const int kMaxWidth = 4096 * 3;
align_buffer_16(src_a, kMaxWidth)
align_buffer_16(src_b, kMaxWidth)
align_buffer_16(src_a, max_width)
align_buffer_16(src_b, max_width)
memset(src_a, 0, kMaxWidth);
memset(src_b, 0, kMaxWidth);
uint64 err;
err = ComputeSumSquareError(src_a, src_b, max_width);
err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
EXPECT_EQ(err, 0);
memset(src_a, 1, max_width);
err = ComputeSumSquareError(src_a, src_b, max_width);
memset(src_a, 1, kMaxWidth);
err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
EXPECT_EQ(err, max_width);
EXPECT_EQ(err, kMaxWidth);
memset(src_a, 190, max_width);
memset(src_b, 193, max_width);
err = ComputeSumSquareError(src_a, src_b, max_width);
memset(src_a, 190, kMaxWidth);
memset(src_b, 193, kMaxWidth);
err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
EXPECT_EQ(err, (max_width*3*3));
EXPECT_EQ(err, (kMaxWidth * 3 * 3));
srandom(time(NULL));
memset(src_a, 0, max_width);
memset(src_b, 0, max_width);
for (int i = 0; i < max_width; ++i) {
for (int i = 0; i < kMaxWidth; ++i) {
src_a[i] = (random() & 0xff);
src_b[i] = (random() & 0xff);
}
MaskCpuFlags(kCpuInitialized);
uint64 c_err = ComputeSumSquareError(src_a, src_b, max_width);
uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
MaskCpuFlags(-1);
uint64 opt_err = ComputeSumSquareError(src_a, src_b, max_width);
uint64 opt_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
EXPECT_EQ(c_err, opt_err);
......@@ -186,6 +193,11 @@ TEST_F(libyuvTest, BenchmarkPsnr_C) {
align_buffer_16(src_a, benchmark_width_ * benchmark_height_)
align_buffer_16(src_b, benchmark_width_ * benchmark_height_)
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
src_a[i] = i;
src_b[i] = i;
}
MaskCpuFlags(kCpuInitialized);
double c_time = get_time();
......@@ -209,6 +221,11 @@ TEST_F(libyuvTest, BenchmarkPsnr_OPT) {
align_buffer_16(src_a, benchmark_width_ * benchmark_height_)
align_buffer_16(src_b, benchmark_width_ * benchmark_height_)
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
src_a[i] = i;
src_b[i] = i;
}
MaskCpuFlags(-1);
double opt_time = get_time();
......@@ -227,75 +244,75 @@ TEST_F(libyuvTest, BenchmarkPsnr_OPT) {
}
TEST_F(libyuvTest, Psnr) {
const int src_width = 1280;
const int src_height = 720;
const int kSrcWidth = 1280;
const int kSrcHeight = 720;
const int b = 128;
const int kSrcPlaneSize = (kSrcWidth + b * 2) * (kSrcHeight + b * 2);
const int kSrcStride = 2 * b + kSrcWidth;
align_buffer_16(src_a, kSrcPlaneSize)
align_buffer_16(src_b, kSrcPlaneSize)
const int src_plane_size = (src_width + (2 * b)) * (src_height + (2 * b));
const int src_stride = 2 * b + src_width;
align_buffer_16(src_a, src_plane_size)
align_buffer_16(src_b, src_plane_size)
memset(src_a, 0, kSrcPlaneSize);
memset(src_b, 0, kSrcPlaneSize);
double err;
err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_EQ(err, kMaxPsnr);
memset(src_a, 255, src_plane_size);
memset(src_a, 255, kSrcPlaneSize);
err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_EQ(err, 0.0);
memset(src_a, 1, src_plane_size);
memset(src_a, 1, kSrcPlaneSize);
err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_GT(err, 48.0);
EXPECT_LT(err, 49.0);
for (int i = 0; i < src_plane_size; ++i)
for (int i = 0; i < kSrcPlaneSize; ++i)
src_a[i] = i;
err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_GT(err, 4.0);
EXPECT_LT(err, 5.0);
srandom(time(NULL));
memset(src_a, 0, src_plane_size);
memset(src_b, 0, src_plane_size);
memset(src_a, 0, kSrcPlaneSize);
memset(src_b, 0, kSrcPlaneSize);
for (int i = b; i < (src_height + b); ++i) {
for (int j = b; j < (src_width + b); ++j) {
src_a[(i * src_stride) + j] = (random() & 0xff);
src_b[(i * src_stride) + j] = (random() & 0xff);
for (int i = b; i < (kSrcHeight + b); ++i) {
for (int j = b; j < (kSrcWidth + b); ++j) {
src_a[(i * kSrcStride) + j] = (random() & 0xff);
src_b[(i * kSrcStride) + j] = (random() & 0xff);
}
}
MaskCpuFlags(kCpuInitialized);
double c_err, opt_err;
c_err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
c_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
MaskCpuFlags(-1);
opt_err = CalcFramePsnr(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
opt_err = CalcFramePsnr(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_EQ(opt_err, c_err);
......@@ -307,6 +324,11 @@ TEST_F(libyuvTest, BenchmarkSsim_C) {
align_buffer_16(src_a, benchmark_width_ * benchmark_height_)
align_buffer_16(src_b, benchmark_width_ * benchmark_height_)
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
src_a[i] = i;
src_b[i] = i;
}
MaskCpuFlags(kCpuInitialized);
double c_time = get_time();
......@@ -330,6 +352,11 @@ TEST_F(libyuvTest, BenchmarkSsim_OPT) {
align_buffer_16(src_a, benchmark_width_ * benchmark_height_)
align_buffer_16(src_b, benchmark_width_ * benchmark_height_)
for (int i = 0; i < benchmark_width_ * benchmark_height_; ++i) {
src_a[i] = i;
src_b[i] = i;
}
MaskCpuFlags(-1);
double opt_time = get_time();
......@@ -348,75 +375,71 @@ TEST_F(libyuvTest, BenchmarkSsim_OPT) {
}
TEST_F(libyuvTest, Ssim) {
const int src_width = 1280;
const int src_height = 720;
const int kSrcWidth = 1280;
const int kSrcHeight = 720;
const int b = 128;
const int kSrcPlaneSize = (kSrcWidth + b * 2) * (kSrcHeight + b * 2);
const int kSrcStride = 2 * b + kSrcWidth;
align_buffer_16(src_a, kSrcPlaneSize)
align_buffer_16(src_b, kSrcPlaneSize)
const int src_plane_size = (src_width + (2 * b)) * (src_height + (2 * b));
const int src_stride = 2 * b + src_width;
align_buffer_16(src_a, src_plane_size)
align_buffer_16(src_b, src_plane_size)
memset(src_a, 0, kSrcPlaneSize);
memset(src_b, 0, kSrcPlaneSize);
double err;
err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_EQ(err, 1.0);
memset(src_a, 255, src_plane_size);
memset(src_a, 255, kSrcPlaneSize);
err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_LT(err, 0.0001);
memset(src_a, 1, src_plane_size);
memset(src_a, 1, kSrcPlaneSize);
err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_GT(err, 0.8);
EXPECT_LT(err, 0.9);
for (int i = 0; i < src_plane_size; ++i)
for (int i = 0; i < kSrcPlaneSize; ++i)
src_a[i] = i;
err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_GT(err, 0.008);
EXPECT_LT(err, 0.009);
srandom(time(NULL));
memset(src_a, 0, src_plane_size);
memset(src_b, 0, src_plane_size);
for (int i = b; i < (src_height + b); ++i) {
for (int j = b; j < (src_width + b); ++j) {
src_a[(i * src_stride) + j] = (random() & 0xff);
src_b[(i * src_stride) + j] = (random() & 0xff);
for (int i = b; i < (kSrcHeight + b); ++i) {
for (int j = b; j < (kSrcWidth + b); ++j) {
src_a[(i * kSrcStride) + j] = (random() & 0xff);
src_b[(i * kSrcStride) + j] = (random() & 0xff);
}
}
MaskCpuFlags(kCpuInitialized);
double c_err, opt_err;
c_err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
c_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
MaskCpuFlags(-1);
opt_err = CalcFrameSsim(src_a + (src_stride * b) + b, src_stride,
src_b + (src_stride * b) + b, src_stride,
src_width, src_height);
opt_err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
src_b + kSrcStride * b + b, kSrcStride,
kSrcWidth, kSrcHeight);
EXPECT_EQ(opt_err, c_err);
......
......@@ -236,14 +236,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) { \
......@@ -279,6 +279,58 @@ TESTATOB(YUY2, 2, 2, ARGB, 4)
TESTATOB(UYVY, 2, 2, ARGB, 4)
TESTATOB(M420, 3 / 2, 1, ARGB, 4)
#define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, FMT_B, BPP_B) \
TEST_F(libyuvTest, ##FMT_A##To##FMT_B##_Random) { \
srandom(time(NULL)); \
for (int times = 0; times < 1000; ++times) { \
const int kWidth = (random() & 63) + 1; \
const int kHeight = (random() & 31) + 1; \
align_buffer_page_end(src_argb, (kWidth * BPP_A) * kHeight); \
align_buffer_page_end(dst_argb_c, (kWidth * BPP_B) * kHeight); \
align_buffer_page_end(dst_argb_opt, (kWidth * BPP_B) * kHeight); \
for (int i = 0; i < kHeight * kWidth * BPP_A; ++i) { \
src_argb[i] = (random() & 0xff); \
} \
MaskCpuFlags(kCpuInitialized); \
##FMT_A##To##FMT_B(src_argb, kWidth * STRIDE_A, \
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); \
int err = 0; \
for (int i = 0; i < kHeight * kWidth * BPP_B; ++i) { \
int diff = static_cast<int>(dst_argb_c[i]) - \
static_cast<int>(dst_argb_opt[i]); \
if (abs(diff) > 2) \
err++; \
} \
EXPECT_EQ(err, 0); \
free_aligned_buffer_page_end(src_argb) \
free_aligned_buffer_page_end(dst_argb_c) \
free_aligned_buffer_page_end(dst_argb_opt) \
} \
}
TESTATOBRANDOM(ARGB, 4, 4, ARGB, 4)
TESTATOBRANDOM(ARGB, 4, 4, BGRA, 4)
TESTATOBRANDOM(ARGB, 4, 4, ABGR, 4)
TESTATOBRANDOM(ARGB, 4, 4, RAW, 3)
TESTATOBRANDOM(ARGB, 4, 4, RGB24, 3)
TESTATOBRANDOM(ARGB, 4, 4, RGB565, 2)
TESTATOBRANDOM(ARGB, 4, 4, ARGB1555, 2)
TESTATOBRANDOM(ARGB, 4, 4, ARGB4444, 2)
TESTATOBRANDOM(BGRA, 4, 4, ARGB, 4)
TESTATOBRANDOM(ABGR, 4, 4, ARGB, 4)
TESTATOBRANDOM(RAW, 3, 3, ARGB, 4)
TESTATOBRANDOM(RGB24, 3, 3, ARGB, 4)
TESTATOBRANDOM(RGB565, 2, 2, ARGB, 4)
TESTATOBRANDOM(ARGB1555, 2, 2, ARGB, 4)
TESTATOBRANDOM(ARGB4444, 2, 2, ARGB, 4)
TEST_F(libyuvTest, TestAttenuate) {
SIMD_ALIGNED(uint8 orig_pixels[256][4]);
SIMD_ALIGNED(uint8 atten_pixels[256][4]);
......@@ -549,4 +601,28 @@ TEST_F(libyuvTest, TestARGBColorMatrix) {
}
}
TEST_F(libyuvTest, TestARGBQuantize) {
SIMD_ALIGNED(uint8 orig_pixels[256][4]);
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;
}
ARGBQuantize(&orig_pixels[0][0], 0,
(65536 + (8 / 2)) / 8, 8, 8 / 2, 0, 0, 256, 1);
for (int i = 0; i < 256; ++i) {
EXPECT_EQ(i / 8 * 8 + 8 / 2, orig_pixels[i][0]);
EXPECT_EQ(i / 2 / 8 * 8 + 8 / 2, orig_pixels[i][1]);
EXPECT_EQ(i / 3 / 8 * 8 + 8 / 2, orig_pixels[i][2]);
EXPECT_EQ(i, orig_pixels[i][3]);
}
for (int i = 0; i < 1000 * 1280 * 720 / 256; ++i) {
ARGBQuantize(&orig_pixels[0][0], 0,
(65536 + (8 / 2)) / 8, 8, 8 / 2, 0, 0, 256, 1);
}
}
} // namespace libyuv
......@@ -17,13 +17,11 @@
namespace libyuv {
void print_array(uint8 *array, int w, int h) {
int i, j;
for (i = 0; i < h; ++i) {
for (j = 0; j < w; ++j)
printf("%4d", (signed char)array[(i * w) + j]);
void PrintArray(uint8 *array, int w, int h) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
printf("%4d", (signed char)array[i * w + j]);
}
printf("\n");
}
}
......@@ -42,26 +40,26 @@ TEST_F(libyuvTest, Transpose) {
align_buffer_16(output_1, ow * oh)
align_buffer_16(output_2, iw * ih)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
TransposePlane(input, iw, output_1, ow, iw, ih);
TransposePlane(output_1, ow, output_2, oh, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_2[i])
err++;
}
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("transpose 1\n");
print_array(output_1, ow, oh);
PrintArray(output_1, ow, oh);
printf("transpose 2\n");
print_array(output_2, iw, ih);
PrintArray(output_2, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -89,7 +87,7 @@ TEST_F(libyuvTest, TransposeUV) {
align_buffer_16(output_a2, iw * ih)
align_buffer_16(output_b2, iw * ih)
for (i = 0; i < (iw * ih); i += 2) {
for (i = 0; i < iw * ih; i += 2) {
input[i] = i >> 1;
input[i + 1] = -(i >> 1);
}
......@@ -99,7 +97,7 @@ TEST_F(libyuvTest, TransposeUV) {
TransposePlane(output_a1, ow, output_a2, oh, ow, oh);
TransposePlane(output_b1, ow, output_b2, oh, ow, oh);
for (i = 0; i < (iw * ih); i += 2) {
for (i = 0; i < iw * ih; i += 2) {
if (input[i] != output_a2[i >> 1])
err++;
if (input[i + 1] != output_b2[i >> 1])
......@@ -108,15 +106,15 @@ TEST_F(libyuvTest, TransposeUV) {
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("transpose 1\n");
print_array(output_a1, ow, oh);
print_array(output_b1, ow, oh);
PrintArray(output_a1, ow, oh);
PrintArray(output_b1, ow, oh);
printf("transpose 2\n");
print_array(output_a2, oh, ow);
print_array(output_b2, oh, ow);
PrintArray(output_a2, oh, ow);
PrintArray(output_b2, oh, ow);
}
free_aligned_buffer_16(input)
......@@ -146,7 +144,7 @@ TEST_F(libyuvTest, RotatePlane90) {
align_buffer_16(output_180, iw * ih)
align_buffer_16(output_270, ow * oh)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane90(input, iw, output_90, ow, iw, ih);
......@@ -154,26 +152,26 @@ TEST_F(libyuvTest, RotatePlane90) {
RotatePlane90(output_180, oh, output_270, ow, oh, ow);
RotatePlane90(output_270, ow, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 90\n");
print_array(output_90, ow, oh);
PrintArray(output_90, ow, oh);
printf("output 180\n");
print_array(output_180, iw, ih);
PrintArray(output_180, iw, ih);
printf("output 270\n");
print_array(output_270, ow, oh);
PrintArray(output_270, ow, oh);
printf("output 0\n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -205,7 +203,7 @@ TEST_F(libyuvTest, RotateUV90) {
align_buffer_16(output_180_u, ow * oh)
align_buffer_16(output_180_v, ow * oh)
for (i = 0; i < (iw * ih); i += 2) {
for (i = 0; i < iw * ih; i += 2) {
input[i] = i >> 1;
input[i + 1] = -(i >> 1);
}
......@@ -227,25 +225,25 @@ TEST_F(libyuvTest, RotateUV90) {
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 90_u\n");
print_array(output_90_u, ow, oh);
PrintArray(output_90_u, ow, oh);
printf("output 90_v\n");
print_array(output_90_v, ow, oh);
PrintArray(output_90_v, ow, oh);
printf("output 180_u\n");
print_array(output_180_u, oh, ow);
PrintArray(output_180_u, oh, ow);
printf("output 180_v\n");
print_array(output_180_v, oh, ow);
PrintArray(output_180_v, oh, ow);
printf("output 0_u\n");
print_array(output_0_u, oh, ow);
PrintArray(output_0_u, oh, ow);
printf("output 0_v\n");
print_array(output_0_v, oh, ow);
PrintArray(output_0_v, oh, ow);
}
free_aligned_buffer_16(input)
......@@ -279,7 +277,7 @@ TEST_F(libyuvTest, RotateUV180) {
align_buffer_16(output_180_u, ow * oh)
align_buffer_16(output_180_v, ow * oh)
for (i = 0; i < (iw * ih); i += 2) {
for (i = 0; i < iw * ih; i += 2) {
input[i] = i >> 1;
input[i + 1] = -(i >> 1);
}
......@@ -301,25 +299,25 @@ TEST_F(libyuvTest, RotateUV180) {
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 180_u\n");
print_array(output_180_u, oh, ow);
PrintArray(output_180_u, oh, ow);
printf("output 180_v\n");
print_array(output_180_v, oh, ow);
PrintArray(output_180_v, oh, ow);
printf("output 90_u\n");
print_array(output_90_u, oh, ow);
PrintArray(output_90_u, oh, ow);
printf("output 90_v\n");
print_array(output_90_v, oh, ow);
PrintArray(output_90_v, oh, ow);
printf("output 0_u\n");
print_array(output_0_u, ow, oh);
PrintArray(output_0_u, ow, oh);
printf("output 0_v\n");
print_array(output_0_v, ow, oh);
PrintArray(output_0_v, ow, oh);
}
free_aligned_buffer_16(input)
......@@ -353,7 +351,7 @@ TEST_F(libyuvTest, RotateUV270) {
align_buffer_16(output_180_u, ow * oh)
align_buffer_16(output_180_v, ow * oh)
for (i = 0; i < (iw * ih); i += 2) {
for (i = 0; i < iw * ih; i += 2) {
input[i] = i >> 1;
input[i + 1] = -(i >> 1);
}
......@@ -376,25 +374,25 @@ TEST_F(libyuvTest, RotateUV270) {
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 270_u\n");
print_array(output_270_u, ow, oh);
PrintArray(output_270_u, ow, oh);
printf("output 270_v\n");
print_array(output_270_v, ow, oh);
PrintArray(output_270_v, ow, oh);
printf("output 180_u\n");
print_array(output_180_u, oh, ow);
PrintArray(output_180_u, oh, ow);
printf("output 180_v\n");
print_array(output_180_v, oh, ow);
PrintArray(output_180_v, oh, ow);
printf("output 0_u\n");
print_array(output_0_u, oh, ow);
PrintArray(output_0_u, oh, ow);
printf("output 0_v\n");
print_array(output_0_v, oh, ow);
PrintArray(output_0_v, oh, ow);
}
free_aligned_buffer_16(input)
......@@ -424,26 +422,26 @@ TEST_F(libyuvTest, RotatePlane180) {
align_buffer_16(output_0, iw * ih)
align_buffer_16(output_180, iw * ih)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane180(input, iw, output_180, ow, iw, ih);
RotatePlane180(output_180, ow, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 180\n");
print_array(output_180, iw, ih);
PrintArray(output_180, iw, ih);
printf("output 0\n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -471,7 +469,7 @@ TEST_F(libyuvTest, RotatePlane270) {
align_buffer_16(output_180, iw * ih)
align_buffer_16(output_270, ow * oh)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane270(input, iw, output_270, ow, iw, ih);
......@@ -479,26 +477,26 @@ TEST_F(libyuvTest, RotatePlane270) {
RotatePlane270(output_180, oh, output_90, ow, oh, ow);
RotatePlane270(output_90, ow, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("input %dx%d \n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output 270\n");
print_array(output_270, ow, oh);
PrintArray(output_270, ow, oh);
printf("output 180\n");
print_array(output_180, iw, ih);
PrintArray(output_180, iw, ih);
printf("output 90\n");
print_array(output_90, ow, oh);
PrintArray(output_90, ow, oh);
printf("output 0\n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -526,26 +524,26 @@ TEST_F(libyuvTest, RotatePlane90and270) {
align_buffer_16(output_0, iw * ih)
align_buffer_16(output_90, ow * oh)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane90(input, iw, output_90, ow, iw, ih);
RotatePlane270(output_90, ow, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("intput %dx%d\n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output \n");
print_array(output_90, ow, oh);
PrintArray(output_90, ow, oh);
printf("output \n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -571,7 +569,7 @@ TEST_F(libyuvTest, RotatePlane90Pitch) {
align_buffer_16(output_0, iw * ih)
align_buffer_16(output_90, ow * oh)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane90(input, iw,
......@@ -589,20 +587,20 @@ TEST_F(libyuvTest, RotatePlane90Pitch) {
RotatePlane270(output_90, ih, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("intput %dx%d\n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output \n");
print_array(output_90, ow, oh);
PrintArray(output_90, ow, oh);
printf("output \n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -628,7 +626,7 @@ TEST_F(libyuvTest, RotatePlane270Pitch) {
align_buffer_16(output_0, iw * ih)
align_buffer_16(output_270, ow * oh)
for (i = 0; i < (iw * ih); ++i)
for (i = 0; i < iw * ih; ++i)
input[i] = i;
RotatePlane270(input, iw,
......@@ -646,20 +644,20 @@ TEST_F(libyuvTest, RotatePlane270Pitch) {
RotatePlane90(output_270, ih, output_0, iw, ow, oh);
for (i = 0; i < (iw * ih); ++i) {
for (i = 0; i < iw * ih; ++i) {
if (input[i] != output_0[i])
err++;
}
if (err) {
printf("intput %dx%d\n", iw, ih);
print_array(input, iw, ih);
PrintArray(input, iw, ih);
printf("output \n");
print_array(output_270, ow, oh);
PrintArray(output_270, ow, oh);
printf("output \n");
print_array(output_0, iw, ih);
PrintArray(output_0, iw, ih);
}
free_aligned_buffer_16(input)
......@@ -681,50 +679,59 @@ TEST_F(libyuvTest, I420Rotate90) {
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_u, uv_plane_size)
align_buffer_16(orig_v, uv_plane_size)
align_buffer_16(ro0_y, y_plane_size)
align_buffer_16(ro0_u, uv_plane_size)
align_buffer_16(ro0_v, uv_plane_size)
align_buffer_16(ro90_y, y_plane_size)
align_buffer_16(ro90_u, uv_plane_size)
align_buffer_16(ro90_v, uv_plane_size)
align_buffer_16(ro270_y, y_plane_size)
align_buffer_16(ro270_u, uv_plane_size)
align_buffer_16(ro270_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_u, 0, uv_plane_size);
memset(orig_v, 0, uv_plane_size);
memset(ro0_y, 0, y_plane_size);
memset(ro0_u, 0, uv_plane_size);
memset(ro0_v, 0, uv_plane_size);
memset(ro90_y, 0, y_plane_size);
memset(ro90_u, 0, uv_plane_size);
memset(ro90_v, 0, uv_plane_size);
memset(ro270_y, 0, y_plane_size);
memset(ro270_u, 0, uv_plane_size);
memset(ro270_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < (uvw + b); ++j) {
orig_u[i * (uvw + (2 * b)) + j] = random() & 0xff;
orig_v[i * (uvw + (2 * b)) + j] = random() & 0xff;
orig_u[i * (uvw + b * 2) + j] = random() & 0xff;
orig_v[i * (uvw + b * 2) + j] = random() & 0xff;
}
}
int y_off_0 = b * (yw + (2 * b)) + b;
int uv_off_0 = b * (uvw + (2 * b)) + b;
int y_off_90 = b * (yh + (2 * b)) + b;
int uv_off_90 = b * (uvh + (2 * b)) + b;
int y_off_0 = b * (yw + b * 2) + b;
int uv_off_0 = b * (uvw + b * 2) + b;
int y_off_90 = b * (yh + b * 2) + b;
int uv_off_90 = b * (uvh + b * 2) + b;
int y_st_0 = yw + (2 * b);
int uv_st_0 = uvw + (2 * b);
int y_st_90 = yh + (2 * b);
int uv_st_90 = uvh + (2 * b);
int y_st_0 = yw + b * 2;
int uv_st_0 = uvw + b * 2;
int y_st_90 = yh + b * 2;
int uv_st_90 = uvh + b * 2;
I420Rotate(orig_y+y_off_0, y_st_0,
orig_u+uv_off_0, uv_st_0,
......@@ -792,50 +799,59 @@ TEST_F(libyuvTest, I420Rotate270) {
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_u, uv_plane_size)
align_buffer_16(orig_v, uv_plane_size)
align_buffer_16(ro0_y, y_plane_size)
align_buffer_16(ro0_u, uv_plane_size)
align_buffer_16(ro0_v, uv_plane_size)
align_buffer_16(ro90_y, y_plane_size)
align_buffer_16(ro90_u, uv_plane_size)
align_buffer_16(ro90_v, uv_plane_size)
align_buffer_16(ro270_y, y_plane_size)
align_buffer_16(ro270_u, uv_plane_size)
align_buffer_16(ro270_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_u, 0, uv_plane_size);
memset(orig_v, 0, uv_plane_size);
memset(ro0_y, 0, y_plane_size);
memset(ro0_u, 0, uv_plane_size);
memset(ro0_v, 0, uv_plane_size);
memset(ro90_y, 0, y_plane_size);
memset(ro90_u, 0, uv_plane_size);
memset(ro90_v, 0, uv_plane_size);
memset(ro270_y, 0, y_plane_size);
memset(ro270_u, 0, uv_plane_size);
memset(ro270_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < (uvw + b); ++j) {
orig_u[i * (uvw + (2 * b)) + j] = random() & 0xff;
orig_v[i * (uvw + (2 * b)) + j] = random() & 0xff;
orig_u[i * (uvw + b * 2) + j] = random() & 0xff;
orig_v[i * (uvw + b * 2) + j] = random() & 0xff;
}
}
int y_off_0 = b * (yw + (2 * b)) + b;
int uv_off_0 = b * (uvw + (2 * b)) + b;
int y_off_90 = b * (yh + (2 * b)) + b;
int uv_off_90 = b * (uvh + (2 * b)) + b;
int y_off_0 = b * (yw + b * 2) + b;
int uv_off_0 = b * (uvw + b * 2) + b;
int y_off_90 = b * (yh + b * 2) + b;
int uv_off_90 = b * (uvh + b * 2) + b;
int y_st_0 = yw + (2 * b);
int uv_st_0 = uvw + (2 * b);
int y_st_90 = yh + (2 * b);
int uv_st_90 = uvh + (2 * b);
int y_st_0 = yw + b * 2;
int uv_st_0 = uvw + b * 2;
int y_st_90 = yh + b * 2;
int uv_st_90 = uvh + b * 2;
I420Rotate(orig_y+y_off_0, y_st_0,
orig_u+uv_off_0, uv_st_0,
......@@ -902,47 +918,53 @@ TEST_F(libyuvTest, NV12ToI420Rotate90) {
int uvh = (yh + 1) >> 1;
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int o_uv_plane_size = ((2 * uvw) + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
int o_uv_plane_size = (uvw * 2 + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_uv, o_uv_plane_size)
align_buffer_16(ro0_y, y_plane_size)
align_buffer_16(ro0_u, uv_plane_size)
align_buffer_16(ro0_v, uv_plane_size)
align_buffer_16(ro90_y, y_plane_size)
align_buffer_16(ro90_u, uv_plane_size)
align_buffer_16(ro90_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_uv, 0, uv_plane_size);
memset(ro0_y, 0, y_plane_size);
memset(ro0_u, 0, uv_plane_size);
memset(ro0_v, 0, uv_plane_size);
memset(ro90_y, 0, y_plane_size);
memset(ro90_u, 0, uv_plane_size);
memset(ro90_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < ((2 * uvw) + b); j += 2) {
for (j = b; j < (uvw * 2 + b); j += 2) {
uint8 random_number = random() & 0x7f;
orig_uv[i * ((2 * uvw) + (2 * b)) + j] = random_number;
orig_uv[i * ((2 * uvw) + (2 * b)) + j + 1] = -random_number;
orig_uv[i * (uvw * 2 + b * 2) + j] = random_number;
orig_uv[i * (uvw * 2 + b * 2) + j + 1] = -random_number;
}
}
int y_off_0 = b * (yw + (2 * b)) + b;
int uv_off_0 = b * (uvw + (2 * b)) + b;
int y_off_90 = b * (yh + (2 * b)) + b;
int uv_off_90 = b * (uvh + (2 * b)) + b;
int y_off_0 = b * (yw + b * 2) + b;
int uv_off_0 = b * (uvw + b * 2) + b;
int y_off_90 = b * (yh + b * 2) + b;
int uv_off_90 = b * (uvh + b * 2) + b;
int y_st_0 = yw + (2 * b);
int uv_st_0 = uvw + (2 * b);
int y_st_90 = yh + (2 * b);
int uv_st_90 = uvh + (2 * b);
int y_st_0 = yw + b * 2;
int uv_st_0 = uvw + b * 2;
int y_st_90 = yh + b * 2;
int uv_st_90 = uvh + b * 2;
NV12ToI420Rotate(orig_y+y_off_0, y_st_0,
orig_uv+y_off_0, y_st_0,
......@@ -1001,47 +1023,53 @@ TEST_F(libyuvTest, NV12ToI420Rotate270) {
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int o_uv_plane_size = ((2 * uvw) + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
int o_uv_plane_size = (uvw * 2 + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_uv, o_uv_plane_size)
align_buffer_16(ro0_y, y_plane_size)
align_buffer_16(ro0_u, uv_plane_size)
align_buffer_16(ro0_v, uv_plane_size)
align_buffer_16(ro270_y, y_plane_size)
align_buffer_16(ro270_u, uv_plane_size)
align_buffer_16(ro270_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_uv, 0, o_uv_plane_size);
memset(ro0_y, 0, y_plane_size);
memset(ro0_u, 0, uv_plane_size);
memset(ro0_v, 0, uv_plane_size);
memset(ro270_y, 0, y_plane_size);
memset(ro270_u, 0, uv_plane_size);
memset(ro270_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < ((2 * uvw) + b); j += 2) {
for (j = b; j < (uvw * 2 + b); j += 2) {
uint8 random_number = random() & 0x7f;
orig_uv[i * ((2 * uvw) + (2 * b)) + j] = random_number;
orig_uv[i * ((2 * uvw) + (2 * b)) + j + 1] = -random_number;
orig_uv[i * (uvw * 2 + b * 2) + j] = random_number;
orig_uv[i * (uvw * 2 + b * 2) + j + 1] = -random_number;
}
}
int y_off_0 = b * (yw + (2 * b)) + b;
int uv_off_0 = b * (uvw + (2 * b)) + b;
int y_off_270 = b * (yh + (2 * b)) + b;
int uv_off_270 = b * (uvh + (2 * b)) + b;
int y_off_0 = b * (yw + b * 2) + b;
int uv_off_0 = b * (uvw + b * 2) + b;
int y_off_270 = b * (yh + b * 2) + b;
int uv_off_270 = b * (uvh + b * 2) + b;
int y_st_0 = yw + (2 * b);
int uv_st_0 = uvw + (2 * b);
int y_st_270 = yh + (2 * b);
int uv_st_270 = uvh + (2 * b);
int y_st_0 = yw + b * 2;
int uv_st_0 = uvw + b * 2;
int y_st_270 = yh + b * 2;
int uv_st_270 = uvh + b * 2;
NV12ToI420Rotate(orig_y+y_off_0, y_st_0,
orig_uv+y_off_0, y_st_0,
......@@ -1100,43 +1128,49 @@ TEST_F(libyuvTest, NV12ToI420Rotate180) {
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int o_uv_plane_size = ((2 * uvw) + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
int o_uv_plane_size = (uvw * 2 + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_uv, o_uv_plane_size)
align_buffer_16(ro0_y, y_plane_size)
align_buffer_16(ro0_u, uv_plane_size)
align_buffer_16(ro0_v, uv_plane_size)
align_buffer_16(ro180_y, y_plane_size)
align_buffer_16(ro180_u, uv_plane_size)
align_buffer_16(ro180_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_uv, 0, o_uv_plane_size);
memset(ro0_y, 0, y_plane_size);
memset(ro0_u, 0, uv_plane_size);
memset(ro0_v, 0, uv_plane_size);
memset(ro180_y, 0, y_plane_size);
memset(ro180_u, 0, uv_plane_size);
memset(ro180_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < ((2 * uvw) + b); j += 2) {
for (j = b; j < (uvw * 2 + b); j += 2) {
uint8 random_number = random() & 0x7f;
orig_uv[i * ((2 * uvw) + (2 * b)) + j] = random_number;
orig_uv[i * ((2 * uvw) + (2 * b)) + j + 1] = -random_number;
orig_uv[i * (uvw * 2 + b * 2) + j] = random_number;
orig_uv[i * (uvw * 2 + b * 2) + j + 1] = -random_number;
}
}
int y_off = b * (yw + (2 * b)) + b;
int uv_off = b * (uvw + (2 * b)) + b;
int y_off = b * (yw + b * 2) + b;
int uv_off = b * (uvw + b * 2) + b;
int y_st = yw + (2 * b);
int uv_st = uvw + (2 * b);
int y_st = yw + b * 2;
int uv_st = uvw + b * 2;
NV12ToI420Rotate(orig_y+y_off, y_st,
orig_uv+y_off, y_st,
......@@ -1194,51 +1228,59 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight90) {
int uvh = (yh + 1) >> 1;
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int o_uv_plane_size = ((2 * uvw) + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
int o_uv_plane_size = (uvw * 2 + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_uv, o_uv_plane_size)
align_buffer_16(roa_y, y_plane_size)
align_buffer_16(roa_u, uv_plane_size)
align_buffer_16(roa_v, uv_plane_size)
align_buffer_16(rob_y, y_plane_size)
align_buffer_16(rob_u, uv_plane_size)
align_buffer_16(rob_v, uv_plane_size)
align_buffer_16(roc_y, y_plane_size)
align_buffer_16(roc_u, uv_plane_size)
align_buffer_16(roc_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_uv, 0, o_uv_plane_size);
memset(roa_y, 0, y_plane_size);
memset(roa_u, 0, uv_plane_size);
memset(roa_v, 0, uv_plane_size);
memset(rob_y, 0, y_plane_size);
memset(rob_u, 0, uv_plane_size);
memset(rob_v, 0, uv_plane_size);
memset(roc_y, 0, y_plane_size);
memset(roc_u, 0, uv_plane_size);
memset(roc_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < ((2 * uvw) + b); j += 2) {
for (j = b; j < (uvw * 2 + b); j += 2) {
uint8 random_number = random() & 0x7f;
orig_uv[i * ((2 * uvw) + (2 * b)) + j] = random_number;
orig_uv[i * ((2 * uvw) + (2 * b)) + j + 1] = -random_number;
orig_uv[i * (uvw * 2 + b * 2) + j] = random_number;
orig_uv[i * (uvw * 2 + b * 2) + j + 1] = -random_number;
}
}
int y_off_0 = b * (yw + (2 * b)) + b;
int uv_off_0 = b * (uvw + (2 * b)) + b;
int y_off_90 = b * (yh + (2 * b)) + b;
int uv_off_90 = b * (uvh + (2 * b)) + b;
int y_off_0 = b * (yw + b * 2) + b;
int uv_off_0 = b * (uvw + b * 2) + b;
int y_off_90 = b * (yh + b * 2) + b;
int uv_off_90 = b * (uvh + b * 2) + b;
int y_st_0 = yw + (2 * b);
int uv_st_0 = uvw + (2 * b);
int y_st_90 = yh + (2 * b);
int uv_st_90 = uvh + (2 * b);
int y_st_0 = yw + b * 2;
int uv_st_0 = uvw + b * 2;
int y_st_90 = yh + b * 2;
int uv_st_90 = uvh + b * 2;
NV12ToI420Rotate(orig_y+y_off_0, y_st_0,
orig_uv+y_off_0, y_st_0,
......@@ -1273,16 +1315,16 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight90) {
if (y_err) {
printf("input %dx%d \n", yw, yh);
print_array(orig_y, y_st_0, yh + (2 * b));
PrintArray(orig_y, y_st_0, yh + b * 2);
printf("rotate a\n");
print_array(roa_y, y_st_90, y_st_0);
PrintArray(roa_y, y_st_90, y_st_0);
printf("rotate b\n");
print_array(rob_y, y_st_90, y_st_0);
PrintArray(rob_y, y_st_90, y_st_0);
printf("rotate c\n");
print_array(roc_y, y_st_0, y_st_90);
PrintArray(roc_y, y_st_0, y_st_90);
}
int zero_cnt = 0;
......@@ -1298,20 +1340,20 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight90) {
++uv_err;
if (uv_err) {
printf("input %dx%d \n", (2 * uvw), uvh);
print_array(orig_uv, y_st_0, uvh + (2 * b));
printf("input %dx%d \n", uvw * 2, uvh);
PrintArray(orig_uv, y_st_0, uvh + b * 2);
printf("rotate a\n");
print_array(roa_u, uv_st_90, uv_st_0);
print_array(roa_v, uv_st_90, uv_st_0);
PrintArray(roa_u, uv_st_90, uv_st_0);
PrintArray(roa_v, uv_st_90, uv_st_0);
printf("rotate b\n");
print_array(rob_u, uv_st_90, uv_st_0);
print_array(rob_v, uv_st_90, uv_st_0);
PrintArray(rob_u, uv_st_90, uv_st_0);
PrintArray(rob_v, uv_st_90, uv_st_0);
printf("rotate c\n");
print_array(roc_u, uv_st_0, uv_st_90);
print_array(roc_v, uv_st_0, uv_st_90);
PrintArray(roc_u, uv_st_0, uv_st_90);
PrintArray(roc_v, uv_st_0, uv_st_90);
}
free_aligned_buffer_16(orig_y)
......@@ -1339,43 +1381,49 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight180) {
int uvh = (yh + 1) >> 1;
int i, j;
int y_plane_size = (yw + (2 * b)) * (yh + (2 * b));
int uv_plane_size = (uvw + (2 * b)) * (uvh + (2 * b));
int o_uv_plane_size = ((2 * uvw) + (2 * b)) * (uvh + (2 * b));
int y_plane_size = (yw + b * 2) * (yh + b * 2);
int uv_plane_size = (uvw + b * 2) * (uvh + b * 2);
int o_uv_plane_size = (uvw * 2 + b * 2) * (uvh + b * 2);
srandom(time(NULL));
align_buffer_16(orig_y, y_plane_size)
align_buffer_16(orig_uv, o_uv_plane_size)
align_buffer_16(roa_y, y_plane_size)
align_buffer_16(roa_u, uv_plane_size)
align_buffer_16(roa_v, uv_plane_size)
align_buffer_16(rob_y, y_plane_size)
align_buffer_16(rob_u, uv_plane_size)
align_buffer_16(rob_v, uv_plane_size)
memset(orig_y, 0, y_plane_size);
memset(orig_uv, 0, o_uv_plane_size);
memset(roa_y, 0, y_plane_size);
memset(roa_u, 0, uv_plane_size);
memset(roa_v, 0, uv_plane_size);
memset(rob_y, 0, y_plane_size);
memset(rob_u, 0, uv_plane_size);
memset(rob_v, 0, uv_plane_size);
// fill image buffers with random data
for (i = b; i < (yh + b); ++i) {
for (j = b; j < (yw + b); ++j) {
orig_y[i * (yw + (2 * b)) + j] = random() & 0xff;
orig_y[i * (yw + b * 2) + j] = random() & 0xff;
}
}
for (i = b; i < (uvh + b); ++i) {
for (j = b; j < ((2 * uvw) + b); j += 2) {
for (j = b; j < (uvw * 2 + b); j += 2) {
uint8 random_number = random() & 0x7f;
orig_uv[i * ((2 * uvw) + (2 * b)) + j] = random_number;
orig_uv[i * ((2 * uvw) + (2 * b)) + j + 1] = -random_number;
orig_uv[i * (uvw * 2 + b * 2) + j] = random_number;
orig_uv[i * (uvw * 2 + b * 2) + j + 1] = -random_number;
}
}
int y_off = b * (yw + (2 * b)) + b;
int uv_off = b * (uvw + (2 * b)) + b;
int y_off = b * (yw + b * 2) + b;
int uv_off = b * (uvw + b * 2) + b;
int y_st = yw + (2 * b);
int uv_st = uvw + (2 * b);
int y_st = yw + b * 2;
int uv_st = uvw + b * 2;
NV12ToI420Rotate(orig_y+y_off, y_st,
orig_uv+y_off, y_st,
......@@ -1401,13 +1449,13 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight180) {
if (y_err) {
printf("input %dx%d \n", yw, yh);
print_array(orig_y, y_st, yh + (2 * b));
PrintArray(orig_y, y_st, yh + b * 2);
printf("rotate a\n");
print_array(roa_y, y_st, yh + (2 * b));
PrintArray(roa_y, y_st, yh + b * 2);
printf("rotate b\n");
print_array(rob_y, y_st, yh + (2 * b));
PrintArray(rob_y, y_st, yh + b * 2);
}
int zero_cnt = 0;
......@@ -1423,16 +1471,16 @@ TEST_F(libyuvTest, NV12ToI420RotateNegHeight180) {
++uv_err;
if (uv_err) {
printf("input %dx%d \n", (2 * uvw), uvh);
print_array(orig_uv, y_st, uvh + (2 * b));
printf("input %dx%d \n", uvw * 2, uvh);
PrintArray(orig_uv, y_st, uvh + b * 2);
printf("rotate a\n");
print_array(roa_u, uv_st, uvh + (2 * b));
print_array(roa_v, uv_st, uvh + (2 * b));
PrintArray(roa_u, uv_st, uvh + b * 2);
PrintArray(roa_v, uv_st, uvh + b * 2);
printf("rotate b\n");
print_array(rob_u, uv_st, uvh + (2 * b));
print_array(rob_v, uv_st, uvh + (2 * b));
PrintArray(rob_u, uv_st, uvh + b * 2);
PrintArray(rob_v, uv_st, uvh + b * 2);
}
free_aligned_buffer_16(orig_y)
......
......@@ -16,16 +16,26 @@
#define align_buffer_16(var, size) \
uint8* var; \
uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(calloc((size) + 15, sizeof(uint8))); \
var##_mem = reinterpret_cast<uint8*>(malloc((size) + 15)); \
var = reinterpret_cast<uint8*> \
((reinterpret_cast<intptr_t>(var##_mem) + 15) & (~0x0f)); \
((reinterpret_cast<intptr_t>(var##_mem) + 15) & ~15);
#define free_aligned_buffer_16(var) \
free(var##_mem); \
var = 0;
#ifdef WIN32
#define align_buffer_page_end(var, size) \
uint8* var; \
uint8* var##_mem; \
var##_mem = reinterpret_cast<uint8*>(malloc(((size) + 4095) & ~4095)); \
var = var##_mem + (-(size) & 4095)
#define free_aligned_buffer_page_end(var) \
free(var##_mem); \
var = 0;
#ifdef WIN32
#include <windows.h>
static double get_time() {
LARGE_INTEGER t, f;
......@@ -47,7 +57,6 @@ static double get_time() {
gettimeofday(&t, &tzp);
return t.tv_sec + t.tv_usec * 1e-6;
}
#endif
class libyuvTest : public ::testing::Test {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment