mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-01-01 03:12:16 +08:00
ARGBInterpolate odd width support and inverted odd width test. ARGBToNV12/21 odd height fix. Compare test tolerate small height with warning.
BUG=202 TEST=libyuvTest.ARGBInterpolate85_Any_Invert Review URL: https://webrtc-codereview.appspot.com/1325004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@663 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
cd6056c01c
commit
4127a2637d
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 662
|
||||
Version: 663
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 662
|
||||
#define LIBYUV_VERSION 663
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||
|
||||
@ -348,7 +348,6 @@ int ARGBToNV12(const uint8* src_argb, int src_stride_argb,
|
||||
ARGBToUVRow(src_argb, 0, row_u, row_v, width);
|
||||
MergeUVRow_(row_u, row_v, dst_uv, halfwidth);
|
||||
ARGBToYRow(src_argb, dst_y, width);
|
||||
ARGBToYRow(src_argb + 0, dst_y + dst_stride_y, width);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -451,7 +450,6 @@ int ARGBToNV21(const uint8* src_argb, int src_stride_argb,
|
||||
ARGBToUVRow(src_argb, 0, row_u, row_v, width);
|
||||
MergeUVRow_(row_v, row_u, dst_uv, halfwidth);
|
||||
ARGBToYRow(src_argb, dst_y, width);
|
||||
ARGBToYRow(src_argb + 0, dst_y + dst_stride_y, width);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -274,12 +274,18 @@ TEST_F(libyuvTest, Ssim) {
|
||||
memset(src_a, 0, kSrcPlaneSize);
|
||||
memset(src_b, 0, kSrcPlaneSize);
|
||||
|
||||
if (kSrcWidth <=8 || kSrcHeight <= 8) {
|
||||
printf("warning - Ssim size too small. Testing function executes.\n");
|
||||
}
|
||||
|
||||
double err;
|
||||
err = CalcFrameSsim(src_a + kSrcStride * b + b, kSrcStride,
|
||||
src_b + kSrcStride * b + b, kSrcStride,
|
||||
kSrcWidth, kSrcHeight);
|
||||
|
||||
EXPECT_EQ(err, 1.0);
|
||||
if (kSrcWidth > 8 && kSrcHeight > 8) {
|
||||
EXPECT_EQ(err, 1.0);
|
||||
}
|
||||
|
||||
memset(src_a, 255, kSrcPlaneSize);
|
||||
|
||||
@ -287,7 +293,9 @@ TEST_F(libyuvTest, Ssim) {
|
||||
src_b + kSrcStride * b + b, kSrcStride,
|
||||
kSrcWidth, kSrcHeight);
|
||||
|
||||
EXPECT_LT(err, 0.0001);
|
||||
if (kSrcWidth > 8 && kSrcHeight > 8) {
|
||||
EXPECT_LT(err, 0.0001);
|
||||
}
|
||||
|
||||
memset(src_a, 1, kSrcPlaneSize);
|
||||
|
||||
@ -295,8 +303,10 @@ TEST_F(libyuvTest, Ssim) {
|
||||
src_b + kSrcStride * b + b, kSrcStride,
|
||||
kSrcWidth, kSrcHeight);
|
||||
|
||||
EXPECT_GT(err, 0.0001);
|
||||
EXPECT_LT(err, 0.9);
|
||||
if (kSrcWidth > 8 && kSrcHeight > 8) {
|
||||
EXPECT_GT(err, 0.0001);
|
||||
EXPECT_LT(err, 0.9);
|
||||
}
|
||||
|
||||
for (int i = 0; i < kSrcPlaneSize; ++i) {
|
||||
src_a[i] = i;
|
||||
@ -306,8 +316,10 @@ TEST_F(libyuvTest, Ssim) {
|
||||
src_b + kSrcStride * b + b, kSrcStride,
|
||||
kSrcWidth, kSrcHeight);
|
||||
|
||||
EXPECT_GT(err, 0.0);
|
||||
EXPECT_LT(err, 0.01);
|
||||
if (kSrcWidth > 8 && kSrcHeight > 8) {
|
||||
EXPECT_GT(err, 0.0);
|
||||
EXPECT_LT(err, 0.01);
|
||||
}
|
||||
|
||||
srandom(time(NULL));
|
||||
for (int i = b; i < (kSrcHeight + b); ++i) {
|
||||
@ -330,7 +342,9 @@ TEST_F(libyuvTest, Ssim) {
|
||||
src_b + kSrcStride * b + b, kSrcStride,
|
||||
kSrcWidth, kSrcHeight);
|
||||
|
||||
EXPECT_EQ(opt_err, c_err);
|
||||
if (kSrcWidth > 8 && kSrcHeight > 8) {
|
||||
EXPECT_EQ(opt_err, c_err);
|
||||
}
|
||||
|
||||
free_aligned_buffer_64(src_a)
|
||||
free_aligned_buffer_64(src_b)
|
||||
|
||||
@ -38,7 +38,7 @@ namespace libyuv {
|
||||
#define TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
|
||||
FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
align_buffer_64(src_y, kWidth * kHeight + OFF); \
|
||||
align_buffer_64(src_u, \
|
||||
@ -173,7 +173,7 @@ TESTPLANARTOP(I444, 1, 1, I444, 1, 1)
|
||||
#define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
|
||||
FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
align_buffer_64(src_y, kWidth * kHeight + OFF); \
|
||||
align_buffer_64(src_u, \
|
||||
@ -276,7 +276,7 @@ TESTPLANARTOBP(I420, 2, 2, NV21, 2, 2)
|
||||
#define TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
|
||||
FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
align_buffer_64(src_y, kWidth * kHeight + OFF); \
|
||||
align_buffer_64(src_uv, 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \
|
||||
@ -392,32 +392,25 @@ TESTBIPLANARTOP(NV21, 2, 2, I420, 2, 2)
|
||||
#define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \
|
||||
TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStrideB = ((kWidth * 8 * BPP_B + 7) / 8 + ALIGN - 1) / \
|
||||
ALIGN * ALIGN; \
|
||||
const int kStrideB = ((kWidth * BPP_B + ALIGN - 1) / ALIGN) * ALIGN; \
|
||||
const int kSizeUV = \
|
||||
SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \
|
||||
align_buffer_64(src_y, kWidth * kHeight + OFF); \
|
||||
align_buffer_64(src_u, \
|
||||
SUBSAMPLE(kWidth, SUBSAMP_X) * \
|
||||
SUBSAMPLE(kHeight, SUBSAMP_Y) + OFF); \
|
||||
align_buffer_64(src_v, \
|
||||
SUBSAMPLE(kWidth, SUBSAMP_X) * \
|
||||
SUBSAMPLE(kHeight, SUBSAMP_Y) + OFF); \
|
||||
align_buffer_64(src_u, kSizeUV + OFF); \
|
||||
align_buffer_64(src_v, kSizeUV + OFF); \
|
||||
align_buffer_64(dst_argb_c, kStrideB * kHeight); \
|
||||
align_buffer_64(dst_argb_opt, kStrideB * kHeight); \
|
||||
memset(dst_argb_c, 0, kStrideB * kHeight); \
|
||||
memset(dst_argb_opt, 0, kStrideB * kHeight); \
|
||||
srandom(time(NULL)); \
|
||||
for (int i = 0; i < kHeight; ++i) { \
|
||||
for (int j = 0; j < kWidth; ++j) { \
|
||||
src_y[(i * kWidth) + j + OFF] = (random() & 0xff); \
|
||||
} \
|
||||
for (int i = 0; i < kWidth * kHeight; ++i) { \
|
||||
src_y[i + OFF] = (random() & 0xff); \
|
||||
} \
|
||||
for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \
|
||||
for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \
|
||||
src_u[(i * SUBSAMPLE(kWidth, SUBSAMP_X)) + j + OFF] = (random() & 0xff); \
|
||||
src_v[(i * SUBSAMPLE(kWidth, SUBSAMP_X)) + j + OFF] = (random() & 0xff); \
|
||||
} \
|
||||
for (int i = 0; i < kSizeUV; ++i) { \
|
||||
src_u[i + OFF] = (random() & 0xff); \
|
||||
src_v[i + OFF] = (random() & 0xff); \
|
||||
} \
|
||||
MaskCpuFlags(0); \
|
||||
FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \
|
||||
@ -445,17 +438,14 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
|
||||
FMT_B##To##FMT_C(dst_argb_opt, kStrideB, \
|
||||
dst_argb32_opt, kWidth * BPP_C , \
|
||||
kWidth, kHeight); \
|
||||
for (int i = 0; i < kHeight; ++i) { \
|
||||
for (int j = 0; j < kWidth * BPP_C ; ++j) { \
|
||||
int abs_diff = \
|
||||
abs(static_cast<int>(dst_argb32_c[i * kWidth * BPP_C + j]) - \
|
||||
static_cast<int>(dst_argb32_opt[i * kWidth * BPP_C + j])); \
|
||||
if (abs_diff > max_diff) { \
|
||||
max_diff = abs_diff; \
|
||||
} \
|
||||
for (int i = 0; i < kWidth * BPP_C * kHeight; ++i) { \
|
||||
int abs_diff = \
|
||||
abs(static_cast<int>(dst_argb32_c[i]) - \
|
||||
static_cast<int>(dst_argb32_opt[i])); \
|
||||
if (abs_diff > max_diff) { \
|
||||
max_diff = abs_diff; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
EXPECT_LE(max_diff, DIFF); \
|
||||
free_aligned_buffer_64(src_y) \
|
||||
free_aligned_buffer_64(src_u) \
|
||||
@ -468,15 +458,17 @@ TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
|
||||
|
||||
#define TESTPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
DIFF, FMT_C, BPP_C) \
|
||||
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \
|
||||
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \
|
||||
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \
|
||||
TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
benchmark_width_, DIFF, _Opt, +, 0, FMT_C, BPP_C)
|
||||
|
||||
// TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
// benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \
|
||||
// TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
// benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \
|
||||
// TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \
|
||||
// benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \
|
||||
|
||||
|
||||
TESTPLANARTOB(I420, 2, 2, ARGB, 4, 4, 2, ARGB, 4)
|
||||
TESTPLANARTOB(I420, 2, 2, BGRA, 4, 4, 2, ARGB, 4)
|
||||
TESTPLANARTOB(I420, 2, 2, ABGR, 4, 4, 2, ARGB, 4)
|
||||
@ -505,7 +497,7 @@ TESTPLANARTOB(I420, 2, 2, BayerGRBG, 1, 1, 2, ARGB, 4)
|
||||
#define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \
|
||||
W1280, DIFF, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, FMT_PLANAR##To##FMT_B##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStrideB = kWidth * BPP_B; \
|
||||
align_buffer_64(src_y, kWidth * kHeight + OFF); \
|
||||
@ -584,7 +576,7 @@ TESTBIPLANARTOB(NV21, 2, 2, RGB565, 2, 9)
|
||||
#define TESTATOPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
|
||||
W1280, DIFF, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \
|
||||
align_buffer_64(src_argb, kStride * kHeight + OFF); \
|
||||
@ -718,7 +710,7 @@ TESTATOPLANAR(BayerGRBG, 1, I420, 2, 2, 4)
|
||||
#define TESTATOBIPLANARI(FMT_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
|
||||
W1280, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, FMT_A##To##FMT_PLANAR##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStride = (kWidth * 8 * BPP_A + 7) / 8; \
|
||||
align_buffer_64(src_argb, kStride * kHeight + OFF); \
|
||||
@ -795,7 +787,7 @@ TESTATOBIPLANAR(ARGB, 4, NV21, 2, 2)
|
||||
FMT_B, BPP_B, STRIDE_B, \
|
||||
W1280, DIFF, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, FMT_A##To##FMT_B##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
|
||||
const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
|
||||
@ -947,8 +939,11 @@ TEST_F(libyuvTest, Test565) {
|
||||
#ifdef HAVE_JPEG
|
||||
TEST_F(libyuvTest, ValidateJpeg) {
|
||||
const int kOff = 10;
|
||||
const int kSize = benchmark_width_ * benchmark_height_ + kOff;
|
||||
align_buffer_64(orig_pixels, benchmark_width_ * benchmark_height_ + kOff);
|
||||
const int kMinJpeg = 64;
|
||||
const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg ?
|
||||
benchmark_width_ * benchmark_height_ : kMinJpeg;
|
||||
const int kSize = kImageSize + kOff;
|
||||
align_buffer_64(orig_pixels, kSize);
|
||||
|
||||
// No SOI or EOI. Expect fail.
|
||||
memset(orig_pixels, 0, kSize);
|
||||
@ -966,7 +961,10 @@ TEST_F(libyuvTest, ValidateJpeg) {
|
||||
|
||||
TEST_F(libyuvTest, InvalidateJpeg) {
|
||||
const int kOff = 10;
|
||||
const int kSize = benchmark_width_ * benchmark_height_ + kOff;
|
||||
const int kMinJpeg = 64;
|
||||
const int kImageSize = benchmark_width_ * benchmark_height_ >= kMinJpeg ?
|
||||
benchmark_width_ * benchmark_height_ : kMinJpeg;
|
||||
const int kSize = kImageSize + kOff;
|
||||
align_buffer_64(orig_pixels, kSize);
|
||||
|
||||
// No SOI or EOI. Expect fail.
|
||||
|
||||
@ -783,7 +783,7 @@ TEST_F(libyuvTest, TestInterpolate) {
|
||||
FMT_B, BPP_B, STRIDE_B, \
|
||||
W1280, TERP, DIFF, N, NEG, OFF) \
|
||||
TEST_F(libyuvTest, ARGBInterpolate##TERP##N) { \
|
||||
const int kWidth = W1280; \
|
||||
const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
|
||||
const int kHeight = benchmark_height_; \
|
||||
const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \
|
||||
const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user