diff options
author | Frank Barchard <fbarchard@google.com> | 2021-10-18 10:36:27 -0700 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-10-18 18:03:28 +0000 |
commit | f0cfc1f1c8a4bf0e9b1e73b6ef87bdfc6e2566ae (patch) | |
tree | 3053a9fb3f96b31cbe35bb847b4eb9e468f6700c /source/scale.cc | |
parent | 55b97cb48f027d2af417ce1f895cefad2ed1ce23 (diff) | |
download | libyuv-f0cfc1f1c8a4bf0e9b1e73b6ef87bdfc6e2566ae.tar.gz |
ubsan friendly unaligned tests
- ubsan complains on unaligned tests when an int16 or int32 is stored unaligned in C.
Although current Intel, ARM, Mips and PPC can do unaligned load/store, its not guaranteed
and could crash a CPU that doesnt support it.
- unaligned tests use offset of 2 or 4, which ubsan accepts.
- unittest fills in random buffer with 2 bytes at a time instead of a short.
- row common functions for int16 types use 2 shorts instead of 1 int.
Bug: libyuv:908, b/203243873
Change-Id: Idf13fa901647d7b0975f1947291caa781999a9bc
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3229782
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Diffstat (limited to 'source/scale.cc')
-rw-r--r-- | source/scale.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/scale.cc b/source/scale.cc index 94a7b89d..619ed6a6 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -50,7 +50,7 @@ static void ScalePlaneDown2(int src_width, ? ScaleRowDown2_C : (filtering == kFilterLinear ? ScaleRowDown2Linear_C : ScaleRowDown2Box_C); - int row_stride = src_stride << 1; + int row_stride = src_stride * 2; (void)src_width; (void)src_height; if (!filtering) { @@ -162,7 +162,7 @@ static void ScalePlaneDown2_16(int src_width, ? ScaleRowDown2_16_C : (filtering == kFilterLinear ? ScaleRowDown2Linear_16_C : ScaleRowDown2Box_16_C); - int row_stride = src_stride << 1; + int row_stride = src_stride * 2; (void)src_width; (void)src_height; if (!filtering) { @@ -222,7 +222,7 @@ static void ScalePlaneDown4(int src_width, void (*ScaleRowDown4)(const uint8_t* src_ptr, ptrdiff_t src_stride, uint8_t* dst_ptr, int dst_width) = filtering ? ScaleRowDown4Box_C : ScaleRowDown4_C; - int row_stride = src_stride << 2; + int row_stride = src_stride * 4; (void)src_width; (void)src_height; if (!filtering) { @@ -298,7 +298,7 @@ static void ScalePlaneDown4_16(int src_width, void (*ScaleRowDown4)(const uint16_t* src_ptr, ptrdiff_t src_stride, uint16_t* dst_ptr, int dst_width) = filtering ? ScaleRowDown4Box_16_C : ScaleRowDown4_16_C; - int row_stride = src_stride << 2; + int row_stride = src_stride * 4; (void)src_width; (void)src_height; if (!filtering) { |