aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2021-02-19 08:58:07 -0800
committerFrank Barchard <fbarchard@chromium.org>2021-02-19 18:04:48 +0000
commit08815a29766a78398a8e2b9ed095280e9d0a73c2 (patch)
treecc3a9bea31747415d3252371014b1066708c079b
parent63dd43dd469c5a21a8fa09d28350961c723326d0 (diff)
downloadlibyuv-08815a29766a78398a8e2b9ed095280e9d0a73c2.tar.gz
Scale 12 functions that are scale 16 but with only low 12 bits valid
Rename yuvconstants to .c and use round from math.h Bug: libyuv:882, b/180472591 Change-Id: I70720bf3e0833ba00df0d721f12020fba0b07a03 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/2706966 Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
-rw-r--r--Android.bp2
-rw-r--r--BUILD.gn8
-rw-r--r--README.chromium2
-rw-r--r--include/libyuv/scale.h38
-rw-r--r--include/libyuv/version.h2
-rw-r--r--linux.mk8
-rw-r--r--source/scale.cc70
-rw-r--r--unit_test/scale_argb_test.cc1
-rw-r--r--unit_test/scale_test.cc155
-rw-r--r--unit_test/scale_uv_test.cc1
-rw-r--r--unit_test/unit_test.cc3
-rw-r--r--util/yuvconstants.c (renamed from util/yuvconstants.cc)19
12 files changed, 207 insertions, 102 deletions
diff --git a/Android.bp b/Android.bp
index ae59dffb..ce1f62e0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -150,7 +150,7 @@ cc_test {
name: "yuvconstants",
gtest: false,
srcs: [
- "util/yuvconstants.cc",
+ "util/yuvconstants.c",
],
static_libs: ["libyuv"],
}
diff --git a/BUILD.gn b/BUILD.gn
index f84144ad..e1c7c1da 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -40,8 +40,8 @@ group("default") {
":i444tonv12_eg",
":libyuv_unittest",
":psnr",
- ":yuvconvert",
":yuvconstants",
+ ":yuvconvert",
]
}
}
@@ -364,7 +364,7 @@ if (libyuv_include_tests) {
executable("yuvconstants") {
sources = [
# sources
- "util/yuvconstants.cc",
+ "util/yuvconstants.c",
]
deps = [ ":libyuv" ]
if (is_linux || is_chromeos) {
@@ -391,9 +391,7 @@ if (libyuv_include_tests) {
# sources
"util/i444tonv12_eg.cc",
]
- deps = [
- ":libyuv",
- ]
+ deps = [ ":libyuv" ]
}
executable("cpuid") {
diff --git a/README.chromium b/README.chromium
index 25445f1a..01b05888 100644
--- a/README.chromium
+++ b/README.chromium
@@ -1,6 +1,6 @@
Name: libyuv
URL: http://code.google.com/p/libyuv/
-Version: 1777
+Version: 1778
License: BSD
License File: LICENSE
diff --git a/include/libyuv/scale.h b/include/libyuv/scale.h
index d06f8b52..3d4b6005 100644
--- a/include/libyuv/scale.h
+++ b/include/libyuv/scale.h
@@ -109,6 +109,25 @@ int I420Scale_16(const uint16_t* src_y,
int dst_height,
enum FilterMode filtering);
+LIBYUV_API
+int I420Scale_12(const uint16_t* src_y,
+ int src_stride_y,
+ const uint16_t* src_u,
+ int src_stride_u,
+ const uint16_t* src_v,
+ int src_stride_v,
+ int src_width,
+ int src_height,
+ uint16_t* dst_y,
+ int dst_stride_y,
+ uint16_t* dst_u,
+ int dst_stride_u,
+ uint16_t* dst_v,
+ int dst_stride_v,
+ int dst_width,
+ int dst_height,
+ enum FilterMode filtering);
+
// Scales a YUV 4:4:4 image from the src width and height to the
// dst width and height.
// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
@@ -157,6 +176,25 @@ int I444Scale_16(const uint16_t* src_y,
int dst_height,
enum FilterMode filtering);
+LIBYUV_API
+int I444Scale_12(const uint16_t* src_y,
+ int src_stride_y,
+ const uint16_t* src_u,
+ int src_stride_u,
+ const uint16_t* src_v,
+ int src_stride_v,
+ int src_width,
+ int src_height,
+ uint16_t* dst_y,
+ int dst_stride_y,
+ uint16_t* dst_u,
+ int dst_stride_u,
+ uint16_t* dst_v,
+ int dst_stride_v,
+ int dst_width,
+ int dst_height,
+ enum FilterMode filtering);
+
// Scales an NV12 image from the src width and height to the
// dst width and height.
// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
diff --git a/include/libyuv/version.h b/include/libyuv/version.h
index 911f038c..ff6531bd 100644
--- a/include/libyuv/version.h
+++ b/include/libyuv/version.h
@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_
-#define LIBYUV_VERSION 1777
+#define LIBYUV_VERSION 1778
#endif // INCLUDE_LIBYUV_VERSION_H_
diff --git a/linux.mk b/linux.mk
index 083f1fa2..f5e73ea4 100644
--- a/linux.mk
+++ b/linux.mk
@@ -75,9 +75,9 @@ libyuv.a: $(LOCAL_OBJ_FILES)
yuvconvert: util/yuvconvert.cc libyuv.a
$(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/yuvconvert.cc libyuv.a
-# A C++ test utility that generates yuvconstants for yuv to rgb.
-yuvconstants: util/yuvconstants.cc libyuv.a
- $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/yuvconstants.cc libyuv.a
+# A C test utility that generates yuvconstants for yuv to rgb.
+yuvconstants: util/yuvconstants.c libyuv.a
+ $(CXX) $(CXXFLAGS) -Iutil/ -lm -o $@ util/yuvconstants.c libyuv.a
# A standalone test utility
psnr: util/psnr.cc
@@ -85,7 +85,7 @@ psnr: util/psnr.cc
# A simple conversion example.
i444tonv12_eg: util/i444tonv12_eg.cc libyuv.a
- $(CC) $(CFLAGS) -o $@ util/i444tonv12_eg.cc libyuv.a
+ $(CXX) $(CXXFLAGS) -o $@ util/i444tonv12_eg.cc libyuv.a
# A C test utility that uses libyuv conversion from C.
# gcc 4.4 and older require -fno-exceptions to avoid link error on __gxx_personality_v0
diff --git a/source/scale.cc b/source/scale.cc
index 5f0ff646..4a5dc94a 100644
--- a/source/scale.cc
+++ b/source/scale.cc
@@ -2073,6 +2073,43 @@ int I420Scale_16(const uint16_t* src_y,
return 0;
}
+LIBYUV_API
+int I420Scale_12(const uint16_t* src_y,
+ int src_stride_y,
+ const uint16_t* src_u,
+ int src_stride_u,
+ const uint16_t* src_v,
+ int src_stride_v,
+ int src_width,
+ int src_height,
+ uint16_t* dst_y,
+ int dst_stride_y,
+ uint16_t* dst_u,
+ int dst_stride_u,
+ uint16_t* dst_v,
+ int dst_stride_v,
+ int dst_width,
+ int dst_height,
+ enum FilterMode filtering) {
+ int src_halfwidth = SUBSAMPLE(src_width, 1, 1);
+ int src_halfheight = SUBSAMPLE(src_height, 1, 1);
+ int dst_halfwidth = SUBSAMPLE(dst_width, 1, 1);
+ int dst_halfheight = SUBSAMPLE(dst_height, 1, 1);
+ if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
+ src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
+ dst_width <= 0 || dst_height <= 0) {
+ return -1;
+ }
+
+ ScalePlane_12(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y,
+ dst_width, dst_height, filtering);
+ ScalePlane_12(src_u, src_stride_u, src_halfwidth, src_halfheight, dst_u,
+ dst_stride_u, dst_halfwidth, dst_halfheight, filtering);
+ ScalePlane_12(src_v, src_stride_v, src_halfwidth, src_halfheight, dst_v,
+ dst_stride_v, dst_halfwidth, dst_halfheight, filtering);
+ return 0;
+}
+
// Scale an I444 image.
// This function in turn calls a scaling function for each plane.
@@ -2142,6 +2179,39 @@ int I444Scale_16(const uint16_t* src_y,
return 0;
}
+LIBYUV_API
+int I444Scale_12(const uint16_t* src_y,
+ int src_stride_y,
+ const uint16_t* src_u,
+ int src_stride_u,
+ const uint16_t* src_v,
+ int src_stride_v,
+ int src_width,
+ int src_height,
+ uint16_t* dst_y,
+ int dst_stride_y,
+ uint16_t* dst_u,
+ int dst_stride_u,
+ uint16_t* dst_v,
+ int dst_stride_v,
+ int dst_width,
+ int dst_height,
+ enum FilterMode filtering) {
+ if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 ||
+ src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v ||
+ dst_width <= 0 || dst_height <= 0) {
+ return -1;
+ }
+
+ ScalePlane_12(src_y, src_stride_y, src_width, src_height, dst_y, dst_stride_y,
+ dst_width, dst_height, filtering);
+ ScalePlane_12(src_u, src_stride_u, src_width, src_height, dst_u, dst_stride_u,
+ dst_width, dst_height, filtering);
+ ScalePlane_12(src_v, src_stride_v, src_width, src_height, dst_v, dst_stride_v,
+ dst_width, dst_height, filtering);
+ return 0;
+}
+
// Scale an NV12 image.
// This function in turn calls a scaling function for each plane.
diff --git a/unit_test/scale_argb_test.cc b/unit_test/scale_argb_test.cc
index c04a236a..ac976612 100644
--- a/unit_test/scale_argb_test.cc
+++ b/unit_test/scale_argb_test.cc
@@ -302,6 +302,7 @@ TEST_FACTOR(3, 1, 3)
TEST_SCALETO1(name, width, height, Bilinear, 3)
TEST_SCALETO(ARGBScale, 1, 1)
+TEST_SCALETO(ARGBScale, 256, 144) /* 128x72 * 2 */
TEST_SCALETO(ARGBScale, 320, 240)
TEST_SCALETO(ARGBScale, 569, 480)
TEST_SCALETO(ARGBScale, 640, 360)
diff --git a/unit_test/scale_test.cc b/unit_test/scale_test.cc
index d5294110..d24806a6 100644
--- a/unit_test/scale_test.cc
+++ b/unit_test/scale_test.cc
@@ -142,9 +142,9 @@ static int I420TestFilter(int src_width,
return max_diff;
}
-// Test scaling with 8 bit C vs 16 bit C and return maximum pixel difference.
+// Test scaling with 8 bit C vs 12 bit C and return maximum pixel difference.
// 0 = exact.
-static int I420TestFilter_16(int src_width,
+static int I420TestFilter_12(int src_width,
int src_height,
int dst_width,
int dst_height,
@@ -169,27 +169,27 @@ static int I420TestFilter_16(int src_width,
align_buffer_page_end(src_y, src_y_plane_size);
align_buffer_page_end(src_u, src_uv_plane_size);
align_buffer_page_end(src_v, src_uv_plane_size);
- align_buffer_page_end(src_y_16, src_y_plane_size * 2);
- align_buffer_page_end(src_u_16, src_uv_plane_size * 2);
- align_buffer_page_end(src_v_16, src_uv_plane_size * 2);
- if (!src_y || !src_u || !src_v || !src_y_16 || !src_u_16 || !src_v_16) {
+ align_buffer_page_end(src_y_12, src_y_plane_size * 2);
+ align_buffer_page_end(src_u_12, src_uv_plane_size * 2);
+ align_buffer_page_end(src_v_12, src_uv_plane_size * 2);
+ if (!src_y || !src_u || !src_v || !src_y_12 || !src_u_12 || !src_v_12) {
printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
return 0;
}
- uint16_t* p_src_y_16 = reinterpret_cast<uint16_t*>(src_y_16);
- uint16_t* p_src_u_16 = reinterpret_cast<uint16_t*>(src_u_16);
- uint16_t* p_src_v_16 = reinterpret_cast<uint16_t*>(src_v_16);
+ uint16_t* p_src_y_12 = reinterpret_cast<uint16_t*>(src_y_12);
+ uint16_t* p_src_u_12 = reinterpret_cast<uint16_t*>(src_u_12);
+ uint16_t* p_src_v_12 = reinterpret_cast<uint16_t*>(src_v_12);
MemRandomize(src_y, src_y_plane_size);
MemRandomize(src_u, src_uv_plane_size);
MemRandomize(src_v, src_uv_plane_size);
for (i = 0; i < src_y_plane_size; ++i) {
- p_src_y_16[i] = src_y[i];
+ p_src_y_12[i] = src_y[i];
}
for (i = 0; i < src_uv_plane_size; ++i) {
- p_src_u_16[i] = src_u[i];
- p_src_v_16[i] = src_v[i];
+ p_src_u_12[i] = src_u[i];
+ p_src_v_12[i] = src_v[i];
}
int dst_width_uv = (dst_width + 1) >> 1;
@@ -204,13 +204,13 @@ static int I420TestFilter_16(int src_width,
align_buffer_page_end(dst_y_8, dst_y_plane_size);
align_buffer_page_end(dst_u_8, dst_uv_plane_size);
align_buffer_page_end(dst_v_8, dst_uv_plane_size);
- align_buffer_page_end(dst_y_16, dst_y_plane_size * 2);
- align_buffer_page_end(dst_u_16, dst_uv_plane_size * 2);
- align_buffer_page_end(dst_v_16, dst_uv_plane_size * 2);
+ align_buffer_page_end(dst_y_12, dst_y_plane_size * 2);
+ align_buffer_page_end(dst_u_12, dst_uv_plane_size * 2);
+ align_buffer_page_end(dst_v_12, dst_uv_plane_size * 2);
- uint16_t* p_dst_y_16 = reinterpret_cast<uint16_t*>(dst_y_16);
- uint16_t* p_dst_u_16 = reinterpret_cast<uint16_t*>(dst_u_16);
- uint16_t* p_dst_v_16 = reinterpret_cast<uint16_t*>(dst_v_16);
+ uint16_t* p_dst_y_12 = reinterpret_cast<uint16_t*>(dst_y_12);
+ uint16_t* p_dst_u_12 = reinterpret_cast<uint16_t*>(dst_u_12);
+ uint16_t* p_dst_v_12 = reinterpret_cast<uint16_t*>(dst_v_12);
MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
I420Scale(src_y, src_stride_y, src_u, src_stride_uv, src_v, src_stride_uv,
@@ -218,26 +218,26 @@ static int I420TestFilter_16(int src_width,
dst_stride_uv, dst_v_8, dst_stride_uv, dst_width, dst_height, f);
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (i = 0; i < benchmark_iterations; ++i) {
- I420Scale_16(p_src_y_16, src_stride_y, p_src_u_16, src_stride_uv,
- p_src_v_16, src_stride_uv, src_width, src_height, p_dst_y_16,
- dst_stride_y, p_dst_u_16, dst_stride_uv, p_dst_v_16,
+ I420Scale_12(p_src_y_12, src_stride_y, p_src_u_12, src_stride_uv,
+ p_src_v_12, src_stride_uv, src_width, src_height, p_dst_y_12,
+ dst_stride_y, p_dst_u_12, dst_stride_uv, p_dst_v_12,
dst_stride_uv, dst_width, dst_height, f);
}
// Expect an exact match.
int max_diff = 0;
for (i = 0; i < dst_y_plane_size; ++i) {
- int abs_diff = Abs(dst_y_8[i] - p_dst_y_16[i]);
+ int abs_diff = Abs(dst_y_8[i] - p_dst_y_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
}
for (i = 0; i < dst_uv_plane_size; ++i) {
- int abs_diff = Abs(dst_u_8[i] - p_dst_u_16[i]);
+ int abs_diff = Abs(dst_u_8[i] - p_dst_u_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
- abs_diff = Abs(dst_v_8[i] - p_dst_v_16[i]);
+ abs_diff = Abs(dst_v_8[i] - p_dst_v_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
@@ -246,15 +246,15 @@ static int I420TestFilter_16(int src_width,
free_aligned_buffer_page_end(dst_y_8);
free_aligned_buffer_page_end(dst_u_8);
free_aligned_buffer_page_end(dst_v_8);
- free_aligned_buffer_page_end(dst_y_16);
- free_aligned_buffer_page_end(dst_u_16);
- free_aligned_buffer_page_end(dst_v_16);
+ free_aligned_buffer_page_end(dst_y_12);
+ free_aligned_buffer_page_end(dst_u_12);
+ free_aligned_buffer_page_end(dst_v_12);
free_aligned_buffer_page_end(src_y);
free_aligned_buffer_page_end(src_u);
free_aligned_buffer_page_end(src_v);
- free_aligned_buffer_page_end(src_y_16);
- free_aligned_buffer_page_end(src_u_16);
- free_aligned_buffer_page_end(src_v_16);
+ free_aligned_buffer_page_end(src_y_12);
+ free_aligned_buffer_page_end(src_u_12);
+ free_aligned_buffer_page_end(src_v_12);
return max_diff;
}
@@ -377,9 +377,9 @@ static int I444TestFilter(int src_width,
return max_diff;
}
-// Test scaling with 8 bit C vs 16 bit C and return maximum pixel difference.
+// Test scaling with 8 bit C vs 12 bit C and return maximum pixel difference.
// 0 = exact.
-static int I444TestFilter_16(int src_width,
+static int I444TestFilter_12(int src_width,
int src_height,
int dst_width,
int dst_height,
@@ -404,27 +404,27 @@ static int I444TestFilter_16(int src_width,
align_buffer_page_end(src_y, src_y_plane_size);
align_buffer_page_end(src_u, src_uv_plane_size);
align_buffer_page_end(src_v, src_uv_plane_size);
- align_buffer_page_end(src_y_16, src_y_plane_size * 2);
- align_buffer_page_end(src_u_16, src_uv_plane_size * 2);
- align_buffer_page_end(src_v_16, src_uv_plane_size * 2);
- if (!src_y || !src_u || !src_v || !src_y_16 || !src_u_16 || !src_v_16) {
+ align_buffer_page_end(src_y_12, src_y_plane_size * 2);
+ align_buffer_page_end(src_u_12, src_uv_plane_size * 2);
+ align_buffer_page_end(src_v_12, src_uv_plane_size * 2);
+ if (!src_y || !src_u || !src_v || !src_y_12 || !src_u_12 || !src_v_12) {
printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
return 0;
}
- uint16_t* p_src_y_16 = reinterpret_cast<uint16_t*>(src_y_16);
- uint16_t* p_src_u_16 = reinterpret_cast<uint16_t*>(src_u_16);
- uint16_t* p_src_v_16 = reinterpret_cast<uint16_t*>(src_v_16);
+ uint16_t* p_src_y_12 = reinterpret_cast<uint16_t*>(src_y_12);
+ uint16_t* p_src_u_12 = reinterpret_cast<uint16_t*>(src_u_12);
+ uint16_t* p_src_v_12 = reinterpret_cast<uint16_t*>(src_v_12);
MemRandomize(src_y, src_y_plane_size);
MemRandomize(src_u, src_uv_plane_size);
MemRandomize(src_v, src_uv_plane_size);
for (i = 0; i < src_y_plane_size; ++i) {
- p_src_y_16[i] = src_y[i];
+ p_src_y_12[i] = src_y[i];
}
for (i = 0; i < src_uv_plane_size; ++i) {
- p_src_u_16[i] = src_u[i];
- p_src_v_16[i] = src_v[i];
+ p_src_u_12[i] = src_u[i];
+ p_src_v_12[i] = src_v[i];
}
int dst_width_uv = dst_width;
@@ -439,13 +439,13 @@ static int I444TestFilter_16(int src_width,
align_buffer_page_end(dst_y_8, dst_y_plane_size);
align_buffer_page_end(dst_u_8, dst_uv_plane_size);
align_buffer_page_end(dst_v_8, dst_uv_plane_size);
- align_buffer_page_end(dst_y_16, dst_y_plane_size * 2);
- align_buffer_page_end(dst_u_16, dst_uv_plane_size * 2);
- align_buffer_page_end(dst_v_16, dst_uv_plane_size * 2);
+ align_buffer_page_end(dst_y_12, dst_y_plane_size * 2);
+ align_buffer_page_end(dst_u_12, dst_uv_plane_size * 2);
+ align_buffer_page_end(dst_v_12, dst_uv_plane_size * 2);
- uint16_t* p_dst_y_16 = reinterpret_cast<uint16_t*>(dst_y_16);
- uint16_t* p_dst_u_16 = reinterpret_cast<uint16_t*>(dst_u_16);
- uint16_t* p_dst_v_16 = reinterpret_cast<uint16_t*>(dst_v_16);
+ uint16_t* p_dst_y_12 = reinterpret_cast<uint16_t*>(dst_y_12);
+ uint16_t* p_dst_u_12 = reinterpret_cast<uint16_t*>(dst_u_12);
+ uint16_t* p_dst_v_12 = reinterpret_cast<uint16_t*>(dst_v_12);
MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
I444Scale(src_y, src_stride_y, src_u, src_stride_uv, src_v, src_stride_uv,
@@ -453,26 +453,26 @@ static int I444TestFilter_16(int src_width,
dst_stride_uv, dst_v_8, dst_stride_uv, dst_width, dst_height, f);
MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
for (i = 0; i < benchmark_iterations; ++i) {
- I444Scale_16(p_src_y_16, src_stride_y, p_src_u_16, src_stride_uv,
- p_src_v_16, src_stride_uv, src_width, src_height, p_dst_y_16,
- dst_stride_y, p_dst_u_16, dst_stride_uv, p_dst_v_16,
+ I444Scale_12(p_src_y_12, src_stride_y, p_src_u_12, src_stride_uv,
+ p_src_v_12, src_stride_uv, src_width, src_height, p_dst_y_12,
+ dst_stride_y, p_dst_u_12, dst_stride_uv, p_dst_v_12,
dst_stride_uv, dst_width, dst_height, f);
}
// Expect an exact match.
int max_diff = 0;
for (i = 0; i < dst_y_plane_size; ++i) {
- int abs_diff = Abs(dst_y_8[i] - p_dst_y_16[i]);
+ int abs_diff = Abs(dst_y_8[i] - p_dst_y_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
}
for (i = 0; i < dst_uv_plane_size; ++i) {
- int abs_diff = Abs(dst_u_8[i] - p_dst_u_16[i]);
+ int abs_diff = Abs(dst_u_8[i] - p_dst_u_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
- abs_diff = Abs(dst_v_8[i] - p_dst_v_16[i]);
+ abs_diff = Abs(dst_v_8[i] - p_dst_v_12[i]);
if (abs_diff > max_diff) {
max_diff = abs_diff;
}
@@ -481,15 +481,15 @@ static int I444TestFilter_16(int src_width,
free_aligned_buffer_page_end(dst_y_8);
free_aligned_buffer_page_end(dst_u_8);
free_aligned_buffer_page_end(dst_v_8);
- free_aligned_buffer_page_end(dst_y_16);
- free_aligned_buffer_page_end(dst_u_16);
- free_aligned_buffer_page_end(dst_v_16);
+ free_aligned_buffer_page_end(dst_y_12);
+ free_aligned_buffer_page_end(dst_u_12);
+ free_aligned_buffer_page_end(dst_v_12);
free_aligned_buffer_page_end(src_y);
free_aligned_buffer_page_end(src_u);
free_aligned_buffer_page_end(src_v);
- free_aligned_buffer_page_end(src_y_16);
- free_aligned_buffer_page_end(src_u_16);
- free_aligned_buffer_page_end(src_v_16);
+ free_aligned_buffer_page_end(src_y_12);
+ free_aligned_buffer_page_end(src_u_12);
+ free_aligned_buffer_page_end(src_v_12);
return max_diff;
}
@@ -621,16 +621,16 @@ static int NV12TestFilter(int src_width,
benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
- TEST_F(LibYUVScaleTest, DISABLED_##I420ScaleDownBy##name##_##filter##_16) { \
- int diff = I420TestFilter_16( \
+ TEST_F(LibYUVScaleTest, DISABLED_##I420ScaleDownBy##name##_##filter##_12) { \
+ int diff = I420TestFilter_12( \
SX(benchmark_width_, nom, denom), SX(benchmark_height_, nom, denom), \
DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
kFilter##filter, benchmark_iterations_, disable_cpu_flags_, \
benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
- TEST_F(LibYUVScaleTest, DISABLED_##I444ScaleDownBy##name##_##filter##_16) { \
- int diff = I444TestFilter_16( \
+ TEST_F(LibYUVScaleTest, DISABLED_##I444ScaleDownBy##name##_##filter##_12) { \
+ int diff = I444TestFilter_12( \
SX(benchmark_width_, nom, denom), SX(benchmark_height_, nom, denom), \
DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
kFilter##filter, benchmark_iterations_, disable_cpu_flags_, \
@@ -687,15 +687,15 @@ TEST_FACTOR(3, 1, 3, 0)
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, \
- DISABLED_##I420##name##To##width##x##height##_##filter##_16) { \
- int diff = I420TestFilter_16( \
+ DISABLED_##I420##name##To##width##x##height##_##filter##_12) { \
+ int diff = I420TestFilter_12( \
benchmark_width_, benchmark_height_, width, height, kFilter##filter, \
benchmark_iterations_, disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, \
- DISABLED_##I444##name##To##width##x##height##_##filter##_16) { \
- int diff = I444TestFilter_16( \
+ DISABLED_##I444##name##To##width##x##height##_##filter##_12) { \
+ int diff = I444TestFilter_12( \
benchmark_width_, benchmark_height_, width, height, kFilter##filter, \
benchmark_iterations_, disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
@@ -721,16 +721,16 @@ TEST_FACTOR(3, 1, 3, 0)
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, \
- DISABLED_##I420##name##From##width##x##height##_##filter##_16) { \
- int diff = I420TestFilter_16(width, height, Abs(benchmark_width_), \
+ DISABLED_##I420##name##From##width##x##height##_##filter##_12) { \
+ int diff = I420TestFilter_12(width, height, Abs(benchmark_width_), \
Abs(benchmark_height_), kFilter##filter, \
benchmark_iterations_, disable_cpu_flags_, \
benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
TEST_F(LibYUVScaleTest, \
- DISABLED_##I444##name##From##width##x##height##_##filter##_16) { \
- int diff = I444TestFilter_16(width, height, Abs(benchmark_width_), \
+ DISABLED_##I444##name##From##width##x##height##_##filter##_12) { \
+ int diff = I444TestFilter_12(width, height, Abs(benchmark_width_), \
Abs(benchmark_height_), kFilter##filter, \
benchmark_iterations_, disable_cpu_flags_, \
benchmark_cpu_info_); \
@@ -761,6 +761,7 @@ TEST_FACTOR(3, 1, 3, 0)
#endif
TEST_SCALETO(Scale, 1, 1)
+TEST_SCALETO(Scale, 256, 144) /* 128x72 * 2 */
TEST_SCALETO(Scale, 320, 240)
TEST_SCALETO(Scale, 569, 480)
TEST_SCALETO(Scale, 640, 360)
@@ -786,15 +787,15 @@ TEST_SCALETO(Scale, 1920, 1080)
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
- TEST_F(LibYUVScaleTest, DISABLED_##I420##name##SwapXY_##filter##_16) { \
- int diff = I420TestFilter_16(benchmark_width_, benchmark_height_, \
+ TEST_F(LibYUVScaleTest, DISABLED_##I420##name##SwapXY_##filter##_12) { \
+ int diff = I420TestFilter_12(benchmark_width_, benchmark_height_, \
benchmark_height_, benchmark_width_, \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_, benchmark_cpu_info_); \
EXPECT_LE(diff, max_diff); \
} \
- TEST_F(LibYUVScaleTest, DISABLED_##I444##name##SwapXY_##filter##_16) { \
- int diff = I444TestFilter_16(benchmark_width_, benchmark_height_, \
+ TEST_F(LibYUVScaleTest, DISABLED_##I444##name##SwapXY_##filter##_12) { \
+ int diff = I444TestFilter_12(benchmark_width_, benchmark_height_, \
benchmark_height_, benchmark_width_, \
kFilter##filter, benchmark_iterations_, \
disable_cpu_flags_, benchmark_cpu_info_); \
@@ -1007,7 +1008,7 @@ TEST_F(LibYUVScaleTest, TestScaleRowDown2Box_16) {
}
#endif // ENABLE_ROW_TESTS
-// Test scaling plane with 8 bit C vs 16 bit C and return maximum pixel
+// Test scaling plane with 8 bit C vs 12 bit C and return maximum pixel
// difference.
// 0 = exact.
static int TestPlaneFilter_16(int src_width,
diff --git a/unit_test/scale_uv_test.cc b/unit_test/scale_uv_test.cc
index e45a25da..59eeee30 100644
--- a/unit_test/scale_uv_test.cc
+++ b/unit_test/scale_uv_test.cc
@@ -166,6 +166,7 @@ TEST_FACTOR(3, 1, 3)
TEST_SCALETO1(name, width, height, Bilinear, 3)
TEST_SCALETO(UVScale, 1, 1)
+TEST_SCALETO(UVScale, 256, 144) /* 128x72 * 2 */
TEST_SCALETO(UVScale, 320, 240)
TEST_SCALETO(UVScale, 569, 480)
TEST_SCALETO(UVScale, 640, 360)
diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc
index 58f7f844..85e3b717 100644
--- a/unit_test/unit_test.cc
+++ b/unit_test/unit_test.cc
@@ -18,9 +18,6 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#endif
-#ifdef LIBYUV_USE_BASE_FLAGS
-#include "base/commandlineflags.h"
-#endif
#include "libyuv/cpu_id.h"
unsigned int fastrand_seed = 0xfb;
diff --git a/util/yuvconstants.cc b/util/yuvconstants.c
index be900878..037e0824 100644
--- a/util/yuvconstants.cc
+++ b/util/yuvconstants.c
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -41,8 +42,6 @@
// #define BG (UG * 128 + VG * 128 + YB)
// #define BR (-VR * 128 + YB)
-#define round(v) ((int)(v + 0.5))
-
int main(int argc, const char* argv[]) {
if (argc < 2) {
printf("yuvconstants Kr Kb\n");
@@ -76,10 +75,10 @@ int main(int argc, const char* argv[]) {
//
// // U and V contributions to R,G,B.
- printf("UB %-3d /* round(%f * 64 = %f) */\n", round(ub * 64), ub, ub * 64);
- printf("UG %-3d /* round(%f * 64 = %f) */\n", round(ug * 64), ug, ug * 64);
- printf("VG %-3d /* round(%f * 64 = %f) */\n", round(vg * 64), vg, vg * 64);
- printf("VR %-3d /* round(%f * 64 = %f) */\n", round(vr * 64), vr, vr * 64);
+ printf("UB %-3.0f /* round(%f * 64 = %8.4f) */\n", round(ub * 64), ub, ub * 64);
+ printf("UG %-3.0f /* round(%f * 64 = %8.4f) */\n", round(ug * 64), ug, ug * 64);
+ printf("VG %-3.0f /* round(%f * 64 = %8.4f) */\n", round(vg * 64), vg, vg * 64);
+ printf("VR %-3.0f /* round(%f * 64 = %8.4f) */\n", round(vr * 64), vr, vr * 64);
vr = 255.f / 224.f * 2 * (1 - kr);
ug = 255.f / 224.f * 2 * ((1 - kb) * kb / kg);
@@ -97,10 +96,10 @@ int main(int argc, const char* argv[]) {
//
// // U and V contributions to R,G,B.
- printf("UB %-3d /* round(%f * 64 = %f) */\n", round(ub * 64), ub, ub * 64);
- printf("UG %-3d /* round(%f * 64 = %f) */\n", round(ug * 64), ug, ug * 64);
- printf("VG %-3d /* round(%f * 64 = %f) */\n", round(vg * 64), vg, vg * 64);
- printf("VR %-3d /* round(%f * 64 = %f) */\n", round(vr * 64), vr, vr * 64);
+ printf("UB %-3.0f /* round(%f * 64 = %8.4f) */\n", round(ub * 64), ub, ub * 64);
+ printf("UG %-3.0f /* round(%f * 64 = %8.4f) */\n", round(ug * 64), ug, ug * 64);
+ printf("VG %-3.0f /* round(%f * 64 = %8.4f) */\n", round(vg * 64), vg, vg * 64);
+ printf("VR %-3.0f /* round(%f * 64 = %8.4f) */\n", round(vr * 64), vr, vr * 64);
return 0;
}