Index: source/scale_common.cc |
diff --git a/source/scale_common.cc b/source/scale_common.cc |
index d3992df2e6a9f5bd97fb34c72f65e50446f7ff1c..baed70b9da1f9c6d705feff6f04bdb4e1c93cc92 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)( \ |