aboutsummaryrefslogtreecommitdiff
path: root/source/scale_common.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2016-06-23 20:16:55 -0700
committerFrank Barchard <fbarchard@google.com>2016-06-23 20:16:55 -0700
commitcc88adc6209f3aa9c25adc6be02743fa2e9e9c80 (patch)
tree19ee3c8b2cdd130c3e6027c302116ca29626c195 /source/scale_common.cc
parent24b9fa6671b7a4d88b77a5cf8cb1f8cc1153cb30 (diff)
downloadlibyuv-cc88adc6209f3aa9c25adc6be02743fa2e9e9c80.tar.gz
YUV scale filter columns improved filtering accuracy
upscale a YUV image. observe change in hue.. green especially. disable ScaleFilterCols_SSSE3, falling back on ScaleFilterCols_C observe hue.. green especially, is better. was ScaleFrom1280x720_Bilinear (1620 ms) now ScaleFrom1280x720_Bilinear (1907 ms) BUG=libyuv:605 TEST=try bots R=harryjin@google.com, wangcheng@google.com Review URL: https://codereview.chromium.org/2084533006 .
Diffstat (limited to 'source/scale_common.cc')
-rw-r--r--source/scale_common.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/scale_common.cc b/source/scale_common.cc
index d3992df2..baed70b9 100644
--- a/source/scale_common.cc
+++ b/source/scale_common.cc
@@ -417,8 +417,16 @@ void ScaleColsUp2_16_C(uint16* dst_ptr, const uint16* src_ptr,
}
// (1-f)a + fb can be replaced with a + f(b-a)
+#if defined(__arm__)
+// arm uses 16 bit math with truncation.
+// TODO(fbarchard): add rounding.
#define BLENDER(a, b, f) (uint8)((int)(a) + \
- ((int)(f) * ((int)(b) - (int)(a)) >> 16))
+ (((int)((f)) * ((int)(b) - (int)(a))) >> 16))
+#else
+// inteluses 7 bit math with rounding.
+#define BLENDER(a, b, f) (uint8)((int)(a) + \
+ (((int)((f) >> 9) * ((int)(b) - (int)(a)) + 0x40) >> 7))
+#endif
void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
int dst_width, int x, int dx) {
@@ -470,8 +478,9 @@ void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
}
#undef BLENDER
+// Same as 8 bit arm blender but return is cast to uint16
#define BLENDER(a, b, f) (uint16)((int)(a) + \
- ((int)(f) * ((int)(b) - (int)(a)) >> 16))
+ (((int)((f)) * ((int)(b) - (int)(a))) >> 16))
void ScaleFilterCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
int dst_width, int x, int dx) {
@@ -809,6 +818,7 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
}
}
+// TODO(fbarchard): Replace 0x7f ^ f with 128-f. bug=605.
// Mimics SSSE3 blender
#define BLENDER1(a, b, f) ((a) * (0x7f ^ f) + (b) * f) >> 7
#define BLENDERC(a, b, f, s) (uint32)( \