mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
Add LIBYUV_SVNREVISION macro and planar unittest fix/improvement
BUG=30 TESTED=libyuvTest.TestVersion Review URL: https://webrtc-codereview.appspot.com/619007 git-svn-id: http://libyuv.googlecode.com/svn/trunk@274 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
7afffcc4d0
commit
b4a1182ffd
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 273
|
||||
Version: 274
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -86,19 +86,22 @@ int RAWToARGB(const uint8* src_raw, int src_stride_raw,
|
||||
uint8* dst_argb, int dst_stride_argb,
|
||||
int width, int height);
|
||||
|
||||
// Deprecated function name.
|
||||
#define BG24ToARGB RGB24ToARGB
|
||||
|
||||
// Convert RGB24 to ARGB.
|
||||
int RGB24ToARGB(const uint8* src_bg24, int src_stride_bg24,
|
||||
uint8* dst_argb, int dst_stride_argb,
|
||||
int width, int height);
|
||||
|
||||
// Deprecated function name.
|
||||
#define BG24ToARGB RGB24ToARGB
|
||||
|
||||
// Convert ABGR to ARGB. Also used for ARGB to ABGR.
|
||||
int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr,
|
||||
uint8* dst_argb, int dst_stride_argb,
|
||||
int width, int height);
|
||||
|
||||
// Palindromes.
|
||||
#define ARGBToBGRA BGRAToARGB
|
||||
|
||||
// Convert BGRA to ARGB. Also used for ARGB to BGRA.
|
||||
int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra,
|
||||
uint8* dst_argb, int dst_stride_argb,
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 273
|
||||
#define LIBYUV_VERSION 274
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
|
||||
@ -17,6 +17,9 @@
|
||||
'testing/gtest.gyp:gtest',
|
||||
'testing/gtest.gyp:gtest_main',
|
||||
],
|
||||
'defines': [
|
||||
'LIBYUV_SVNREVISION="<!(svnversion -n)"',
|
||||
],
|
||||
'sources': [
|
||||
# headers
|
||||
'unit_test/unit_test.h',
|
||||
@ -29,6 +32,7 @@
|
||||
'unit_test/scale_test.cc',
|
||||
'unit_test/scale_argb_test.cc',
|
||||
'unit_test/unit_test.cc',
|
||||
'unit_test/version_test.cc',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
|
||||
@ -18,10 +18,6 @@
|
||||
|
||||
namespace libyuv {
|
||||
|
||||
TEST_F(libyuvTest, TestVersion) {
|
||||
EXPECT_GE(LIBYUV_VERSION, 169); // 169 is first version to support version.
|
||||
}
|
||||
|
||||
TEST_F(libyuvTest, TestCpuHas) {
|
||||
int cpu_flags = TestCpuFlag(~kCpuInitialized);
|
||||
printf("Cpu Flags %x\n", cpu_flags);
|
||||
|
||||
@ -69,41 +69,41 @@ TEST_F(libyuvTest, BenchmarkI420ToARGB_OPT) {
|
||||
free_aligned_buffer_16(dst_argb)
|
||||
}
|
||||
|
||||
#define TESTI420TO(FMT) \
|
||||
#define TESTI420TO(FMT, BPP) \
|
||||
TEST_F(libyuvTest, I420To##FMT##_CvsOPT) { \
|
||||
const int src_width = 1280; \
|
||||
const int src_height = 720; \
|
||||
align_buffer_16(src_y, src_width * src_height); \
|
||||
align_buffer_16(src_u, (src_width * src_height) >> 2); \
|
||||
align_buffer_16(src_v, (src_width * src_height) >> 2); \
|
||||
align_buffer_16(dst_rgb_c, (src_width << 2) * src_height); \
|
||||
align_buffer_16(dst_rgb_opt, (src_width << 2) * src_height); \
|
||||
align_buffer_16(dst_rgb_c, (src_width * BPP) * src_height); \
|
||||
align_buffer_16(dst_rgb_opt, (src_width * BPP) * src_height); \
|
||||
srandom(time(NULL)); \
|
||||
for (int i = 0; i < src_height; ++i) \
|
||||
for (int j = 0; j < src_width; ++j) \
|
||||
src_y[(i * src_height) + j] = (random() & 0xff); \
|
||||
src_y[(i * src_width) + j] = (random() & 0xff); \
|
||||
for (int i = 0; i < src_height >> 1; ++i) \
|
||||
for (int j = 0; j < src_width >> 1; ++j) { \
|
||||
src_u[(i * src_height >> 1) + j] = (random() & 0xff); \
|
||||
src_v[(i * src_height >> 1) + j] = (random() & 0xff); \
|
||||
src_u[(i * src_width >> 1) + j] = (random() & 0xff); \
|
||||
src_v[(i * src_width >> 1) + j] = (random() & 0xff); \
|
||||
} \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
I420To##FMT(src_y, src_width, \
|
||||
src_u, src_width >> 1, \
|
||||
src_v, src_width >> 1, \
|
||||
dst_rgb_c, src_width << 2, \
|
||||
dst_rgb_c, src_width * BPP, \
|
||||
src_width, src_height); \
|
||||
MaskCpuFlags(-1); \
|
||||
I420To##FMT(src_y, src_width, \
|
||||
src_u, src_width >> 1, \
|
||||
src_v, src_width >> 1, \
|
||||
dst_rgb_opt, src_width << 2, \
|
||||
dst_rgb_opt, src_width * BPP, \
|
||||
src_width, src_height); \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < src_height; ++i) { \
|
||||
for (int j = 0; j < src_width << 2; ++j) { \
|
||||
int diff = static_cast<int>(dst_rgb_c[i * src_height + j]) - \
|
||||
static_cast<int>(dst_rgb_opt[i * src_height + j]); \
|
||||
for (int j = 0; j < src_width * BPP; ++j) { \
|
||||
int diff = static_cast<int>(dst_rgb_c[i * src_width * BPP + j]) - \
|
||||
static_cast<int>(dst_rgb_opt[i * src_width * BPP + j]); \
|
||||
if (abs(diff) > 2) \
|
||||
err++; \
|
||||
} \
|
||||
@ -116,9 +116,58 @@ TEST_F(libyuvTest, I420To##FMT##_CvsOPT) { \
|
||||
free_aligned_buffer_16(dst_rgb_opt) \
|
||||
}
|
||||
|
||||
TESTI420TO(ARGB)
|
||||
TESTI420TO(BGRA)
|
||||
TESTI420TO(ABGR)
|
||||
TESTI420TO(ARGB, 4)
|
||||
TESTI420TO(BGRA, 4)
|
||||
TESTI420TO(ABGR, 4)
|
||||
TESTI420TO(RAW, 3)
|
||||
TESTI420TO(RGB24, 3)
|
||||
TESTI420TO(RGB565, 2)
|
||||
// TODO(fbarchard): Add 555/4444 unittests once passing.
|
||||
//TESTI420TO(ARGB1555, 2)
|
||||
//TESTI420TO(ARGB4444, 2)
|
||||
|
||||
#define TESTARGBTO(FMT, BPP) \
|
||||
TEST_F(libyuvTest, ARGBTo##FMT##_CvsOPT) { \
|
||||
const int src_width = 1280; \
|
||||
const int src_height = 720; \
|
||||
align_buffer_16(src_argb, src_width * src_height * 4); \
|
||||
align_buffer_16(dst_rgb_c, (src_width * BPP) * src_height); \
|
||||
align_buffer_16(dst_rgb_opt, (src_width * BPP) * src_height); \
|
||||
srandom(time(NULL)); \
|
||||
for (int i = 0; i < src_height; ++i) \
|
||||
for (int j = 0; j < src_width * 4; ++j) \
|
||||
src_argb[(i * src_width * 4) + j] = (random() & 0xff); \
|
||||
MaskCpuFlags(kCpuInitialized); \
|
||||
ARGBTo##FMT(src_argb, src_width * 4, \
|
||||
dst_rgb_c, src_width * BPP, \
|
||||
src_width, src_height); \
|
||||
MaskCpuFlags(-1); \
|
||||
ARGBTo##FMT(src_argb, src_width * 4, \
|
||||
dst_rgb_opt, src_width * BPP, \
|
||||
src_width, src_height); \
|
||||
int err = 0; \
|
||||
for (int i = 0; i < src_height; ++i) { \
|
||||
for (int j = 0; j < src_width * BPP; ++j) { \
|
||||
int diff = static_cast<int>(dst_rgb_c[i * src_width * BPP + j]) - \
|
||||
static_cast<int>(dst_rgb_opt[i * src_width * BPP + j]); \
|
||||
if (abs(diff) > 2) \
|
||||
err++; \
|
||||
} \
|
||||
} \
|
||||
EXPECT_EQ(err, 0); \
|
||||
free_aligned_buffer_16(src_argb) \
|
||||
free_aligned_buffer_16(dst_rgb_c) \
|
||||
free_aligned_buffer_16(dst_rgb_opt) \
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Expose all ARGBToRGB functions and test.
|
||||
//TESTARGBTO(BGRA, 4)
|
||||
//TESTARGBTO(ABGR, 4)
|
||||
TESTARGBTO(RAW, 3)
|
||||
TESTARGBTO(RGB24, 3)
|
||||
//TESTARGBTO(RGB565, 2)
|
||||
//TESTARGBTO(ARGB1555, 2)
|
||||
//TESTARGBTO(ARGB4444, 2)
|
||||
|
||||
TEST_F(libyuvTest, TestAttenuate) {
|
||||
SIMD_ALIGNED(uint8 orig_pixels[256][4]);
|
||||
|
||||
34
unit_test/version_test.cc
Normal file
34
unit_test/version_test.cc
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The LibYuv project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/version.h"
|
||||
#include "unit_test/unit_test.h"
|
||||
|
||||
namespace libyuv {
|
||||
|
||||
TEST_F(libyuvTest, TestVersion) {
|
||||
EXPECT_GE(LIBYUV_VERSION, 169); // 169 is first version to support version.
|
||||
printf("LIBYUV_VERSION %d\n", LIBYUV_VERSION);
|
||||
#ifdef LIBYUV_SVNREVISION
|
||||
const char *ver = strchr(LIBYUV_SVNREVISION, ':');
|
||||
if (!ver) {
|
||||
ver = LIBYUV_SVNREVISION;
|
||||
}
|
||||
int svn_revision = atoi(ver);
|
||||
printf("LIBYUV_SVNREVISION %d\n", svn_revision);
|
||||
EXPECT_GE(LIBYUV_VERSION, svn_revision);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace libyuv
|
||||
Loading…
x
Reference in New Issue
Block a user