From 1c5136d0699d8705971d765902ae692759f15d21 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Tue, 22 Nov 2011 18:15:17 +0000 Subject: [PATCH] use IS_ALIGNED for width and stride to avoid mod that generates 6 instructions BUG=none TEST=disassemble to confirm smaller/simplier alignment checks Review URL: http://webrtc-codereview.appspot.com/287001 git-svn-id: http://libyuv.googlecode.com/svn/trunk@91 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- source/compare.cc | 2 +- source/convert.cc | 90 ++++++++++---------- source/format_conversion.cc | 20 ++--- source/planar_functions.cc | 162 ++++++++++++++++++------------------ source/rotate.cc | 34 ++++---- source/row.h | 1 + source/scale.cc | 67 ++++++++------- 7 files changed, 188 insertions(+), 188 deletions(-) diff --git a/source/compare.cc b/source/compare.cc index 9ec19ef75..42a8842d9 100644 --- a/source/compare.cc +++ b/source/compare.cc @@ -204,7 +204,7 @@ uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, const uint8* src_b, int count); #if defined(HAS_SUMSQUAREERROR_NEON) if (TestCpuFlag(kCpuHasNEON) && - (width % 16 == 0)) { + IS_ALIGNED(width, 16)) { SumSquareError = SumSquareError_NEON; } else #endif diff --git a/source/convert.cc b/source/convert.cc index fb5dd58f1..09cad217c 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -435,9 +435,9 @@ int I422ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_v, uint8* dst_frame, int width); #if defined(HAS_I42XTOYUY2ROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(src_y, 16) && (src_stride_y % 16 == 0) && - IS_ALIGNED(dst_frame, 16) && (dst_stride_frame % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16) && + IS_ALIGNED(dst_frame, 16) && IS_ALIGNED(dst_stride_frame, 16)) { I42xToYUY2Row = I42xToYUY2Row_SSE2; } else #endif @@ -472,9 +472,9 @@ int I420ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_v, uint8* dst_frame, int width); #if defined(HAS_I42XTOYUY2ROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(src_y, 16) && (src_stride_y % 16 == 0) && - IS_ALIGNED(dst_frame, 16) && (dst_stride_frame % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16) && + IS_ALIGNED(dst_frame, 16) && IS_ALIGNED(dst_stride_frame, 16)) { I42xToYUY2Row = I42xToYUY2Row_SSE2; } else #endif @@ -721,9 +721,9 @@ int ARGBToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_u, uint8* dst_v, int width); #if defined(HAS_ARGBTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = ARGBToYRow_SSSE3; } else #endif @@ -732,10 +732,10 @@ int ARGBToI420(const uint8* src_frame, int src_stride_frame, } #if defined(HAS_ARGBTOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = ARGBToUVRow_SSSE3; } else #endif @@ -774,9 +774,9 @@ int BGRAToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_u, uint8* dst_v, int width); #if defined(HAS_BGRATOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = BGRAToYRow_SSSE3; } else #endif @@ -785,10 +785,10 @@ int BGRAToI420(const uint8* src_frame, int src_stride_frame, } #if defined(HAS_BGRATOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = BGRAToUVRow_SSSE3; } else #endif @@ -827,9 +827,9 @@ int ABGRToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_u, uint8* dst_v, int width); #if defined(HAS_ABGRTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = ABGRToYRow_SSSE3; } else #endif @@ -838,10 +838,10 @@ int ABGRToI420(const uint8* src_frame, int src_stride_frame, } #if defined(HAS_ABGRTOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = ABGRToUVRow_SSSE3; } else #endif @@ -880,9 +880,9 @@ int RGB24ToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_u, uint8* dst_v, int width); #if defined(HAS_RGB24TOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = RGB24ToYRow_SSSE3; } else #endif @@ -891,10 +891,10 @@ int RGB24ToI420(const uint8* src_frame, int src_stride_frame, } #if defined(HAS_RGB24TOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = RGB24ToUVRow_SSSE3; } else #endif @@ -919,10 +919,10 @@ int RGB24ToI420(const uint8* src_frame, int src_stride_frame, } int RAWToI420(const uint8* src_frame, int src_stride_frame, - uint8* dst_y, int dst_stride_y, - uint8* dst_u, int dst_stride_u, - uint8* dst_v, int dst_stride_v, - int width, int height) { + uint8* dst_y, int dst_stride_y, + uint8* dst_u, int dst_stride_u, + uint8* dst_v, int dst_stride_v, + int width, int height) { if (height < 0) { height = -height; src_frame = src_frame + (height - 1) * src_stride_frame; @@ -933,9 +933,9 @@ int RAWToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_u, uint8* dst_v, int width); #if defined(HAS_RAWTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = RAWToYRow_SSSE3; } else #endif @@ -944,10 +944,10 @@ int RAWToI420(const uint8* src_frame, int src_stride_frame, } #if defined(HAS_RAWTOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_frame, 16) && (src_stride_frame % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_frame, 16) && IS_ALIGNED(src_stride_frame, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = RAWToUVRow_SSSE3; } else #endif diff --git a/source/format_conversion.cc b/source/format_conversion.cc index 13ccdc989..5f9f87e71 100644 --- a/source/format_conversion.cc +++ b/source/format_conversion.cc @@ -112,9 +112,9 @@ int ARGBToBayerRGB(const uint8* src_rgb, int src_stride_rgb, uint8* dst_bayer, uint32 selector, int pix); #if defined(HAS_ARGBTOBAYERROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 4 == 0) && - IS_ALIGNED(src_rgb, 16) && (src_stride_rgb % 16 == 0) && - IS_ALIGNED(dst_bayer, 4) && (dst_stride_bayer % 4 == 0)) { + IS_ALIGNED(width, 4) && + IS_ALIGNED(src_rgb, 16) && IS_ALIGNED(src_stride_rgb, 16) && + IS_ALIGNED(dst_bayer, 4) && IS_ALIGNED(dst_stride_bayer, 4)) { ARGBToBayerRow = ARGBToBayerRow_SSSE3; } else #endif @@ -366,9 +366,9 @@ int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer, #if defined(HAS_ARGBTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(row, 16) && (kMaxStride % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(row, 16) && IS_ALIGNED(kMaxStride, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = ARGBToYRow_SSSE3; } else #endif @@ -377,10 +377,10 @@ int BayerRGBToI420(const uint8* src_bayer, int src_stride_bayer, } #if defined(HAS_ARGBTOUVROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(row, 16) && (kMaxStride % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(row, 16) && IS_ALIGNED(kMaxStride, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { ARGBToUVRow = ARGBToUVRow_SSSE3; } else #endif diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 85ae29e63..177a3302b 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -183,8 +183,8 @@ static void CopyPlane(const uint8* src_y, int src_stride_y, void (*CopyRow)(const uint8* src, uint8* dst, int width); #if defined(HAS_COPYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 32 == 0) && - IS_ALIGNED(src_y, 16) && (src_stride_y % 16 == 0)) { + IS_ALIGNED(width, 32) && + IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16)) { CopyRow = CopyRow_SSE2; } else #endif @@ -262,19 +262,19 @@ int I420Mirror(const uint8* src_y, int src_stride_y, void (*ReverseRow)(const uint8* src, uint8* dst, int width); #if defined(HAS_REVERSE_ROW_NEON) if (TestCpuFlag(kCpuHasNEON) && - (width % 32 == 0)) { + IS_ALIGNED(width, 32)) { ReverseRow = ReverseRow_NEON; } else #endif #if defined(HAS_REVERSE_ROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 32 == 0) && - IS_ALIGNED(src_y, 16) && (src_stride_y % 16 == 0) && - IS_ALIGNED(src_u, 16) && (src_stride_u % 16 == 0) && - IS_ALIGNED(src_v, 16) && (src_stride_v % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0) && - IS_ALIGNED(dst_u, 16) && (dst_stride_u % 16 == 0) && - IS_ALIGNED(dst_v, 16) && (dst_stride_v % 16 == 0)) { + IS_ALIGNED(width, 32) && + IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16) && + IS_ALIGNED(src_u, 16) && IS_ALIGNED(src_stride_u, 16) && + IS_ALIGNED(src_v, 16) && IS_ALIGNED(src_stride_v, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16) && + IS_ALIGNED(dst_u, 16) && IS_ALIGNED(dst_stride_u, 16) && + IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) { ReverseRow = ReverseRow_SSSE3; } else #endif @@ -374,14 +374,14 @@ static void I420SetPlane(uint8* dst_y, int dst_stride_y, void (*SetRow)(uint8* dst, uint32 value, int pix); #if defined(HAS_SETROW_NEON) if (TestCpuFlag(kCpuHasNEON) && - (width % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { SetRow = SetRow32_NEON; } else #elif defined(HAS_SETROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { SetRow = SetRow32_SSE2; } else #endif @@ -515,11 +515,11 @@ int I422ToI420(const uint8* src_y, int src_stride_y, uint8* dst_uv, int pix); #if defined(HAS_HALFROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (halfwidth % 16 == 0) && - IS_ALIGNED(src_u, 16) && (src_stride_u % 16 == 0) && - IS_ALIGNED(src_v, 16) && (src_stride_v % 16 == 0) && - IS_ALIGNED(dst_u, 16) && (dst_stride_u % 16 == 0) && - IS_ALIGNED(dst_v, 16) && (dst_stride_v % 16 == 0)) { + IS_ALIGNED(halfwidth, 16) && + IS_ALIGNED(src_u, 16) && IS_ALIGNED(src_stride_u, 16) && + IS_ALIGNED(src_v, 16) && IS_ALIGNED(src_stride_v, 16) && + IS_ALIGNED(dst_u, 16) && IS_ALIGNED(dst_stride_u, 16) && + IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) { HalfRow = HalfRow_SSE2; } else #endif @@ -636,17 +636,17 @@ int I444ToI420(const uint8* src_y, int src_stride_y, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN2_NEON) if (TestCpuFlag(kCpuHasNEON) && - (halfwidth % 16 == 0)) { + IS_ALIGNED(halfwidth, 16)) { ScaleRowDown2 = ScaleRowDown2Int_NEON; } else #endif #if defined(HAS_SCALEROWDOWN2_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (halfwidth % 16 == 0) && - IS_ALIGNED(src_u, 16) && (src_stride_u % 16 == 0) && - IS_ALIGNED(src_v, 16) && (src_stride_v % 16 == 0) && - IS_ALIGNED(dst_u, 16) && (dst_stride_u % 16 == 0) && - IS_ALIGNED(dst_v, 16) && (dst_stride_v % 16 == 0)) { + IS_ALIGNED(halfwidth, 16) && + IS_ALIGNED(src_u, 16) && IS_ALIGNED(src_stride_u, 16) && + IS_ALIGNED(src_v, 16) && IS_ALIGNED(src_stride_v, 16) && + IS_ALIGNED(dst_u, 16) && IS_ALIGNED(dst_stride_u, 16) && + IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) { ScaleRowDown2 = ScaleRowDown2Int_SSE2; #endif { @@ -725,18 +725,18 @@ static int X420ToI420(const uint8* src_y, void (*SplitUV)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix); #if defined(HAS_SPLITUV_NEON) if (TestCpuFlag(kCpuHasNEON) && - (halfwidth % 16 == 0) && - IS_ALIGNED(src_uv, 16) && (src_stride_uv % 16 == 0) && - IS_ALIGNED(dst_u, 16) && (dst_stride_u % 16 == 0) && - IS_ALIGNED(dst_v, 16) && (dst_stride_v % 16 == 0)) { + IS_ALIGNED(halfwidth, 16) && + IS_ALIGNED(src_uv, 16) && IS_ALIGNED(src_stride_uv, 16) && + IS_ALIGNED(dst_u, 16) && IS_ALIGNED(dst_stride_u, 16) && + IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) { SplitUV = SplitUV_NEON; } else #elif defined(HAS_SPLITUV_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (halfwidth % 16 == 0) && - IS_ALIGNED(src_uv, 16) && (src_stride_uv % 16 == 0) && - IS_ALIGNED(dst_u, 16) && (dst_stride_u % 16 == 0) && - IS_ALIGNED(dst_v, 16) && (dst_stride_v % 16 == 0)) { + IS_ALIGNED(halfwidth, 16) && + IS_ALIGNED(src_uv, 16) && IS_ALIGNED(src_stride_uv, 16) && + IS_ALIGNED(dst_u, 16) && IS_ALIGNED(dst_stride_u, 16) && + IS_ALIGNED(dst_v, 16) && IS_ALIGNED(dst_stride_v, 16)) { SplitUV = SplitUV_SSE2; } else #endif @@ -935,11 +935,11 @@ int Q420ToI420(const uint8* src_y, int src_stride_y, uint8* dst_y, uint8* dst_u, uint8* dst_v, int pix); #if defined(HAS_SPLITYUY2_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(src_yuy2, 16) && (src_stride_yuy2 % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_yuy2, 16) && IS_ALIGNED(src_stride_yuy2, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { SplitYUY2 = SplitYUY2_SSE2; } else #endif @@ -1295,11 +1295,11 @@ int YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_y, int pix); #if defined(HAS_YUY2TOI420ROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(src_yuy2, 16) && (src_stride_yuy2 % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_yuy2, 16) && IS_ALIGNED(src_stride_yuy2, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { YUY2ToI420RowY = YUY2ToI420RowY_SSE2; YUY2ToI420RowUV = YUY2ToI420RowUV_SSE2; } else @@ -1342,11 +1342,11 @@ int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_y, int pix); #if defined(HAS_UYVYTOI420ROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 16 == 0) && - IS_ALIGNED(src_uyvy, 16) && (src_stride_uyvy % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0) && - IS_ALIGNED(dst_u, 8) && (dst_stride_u % 8 == 0) && - IS_ALIGNED(dst_v, 8) && (dst_stride_v % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_uyvy, 16) && IS_ALIGNED(src_stride_uyvy, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16) && + IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) && + IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) { UYVYToI420RowY = UYVYToI420RowY_SSE2; UYVYToI420RowUV = UYVYToI420RowUV_SSE2; } else @@ -1389,13 +1389,13 @@ int I420ToARGB(const uint8* src_y, int src_stride_y, uint8* rgb_buf, int width); #if defined(HAS_FASTCONVERTYUVTOARGBROW_NEON) - if (TestCpuFlag(kCpuHasNEON) && (width % 16 == 0)) { + if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) { FastConvertYUVToARGBRow = FastConvertYUVToARGBRow_NEON; } else #elif defined(HAS_FASTCONVERTYUVTOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYUVToARGBRow = FastConvertYUVToARGBRow_SSSE3; } else #endif @@ -1432,13 +1432,13 @@ int I420ToBGRA(const uint8* src_y, int src_stride_y, uint8* rgb_buf, int width); #if defined(HAS_FASTCONVERTYUVTOBGRAROW_NEON) - if (TestCpuFlag(kCpuHasNEON) && (width % 16 == 0)) { + if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) { FastConvertYUVToBGRARow = FastConvertYUVToBGRARow_NEON; } else #elif defined(HAS_FASTCONVERTYUVTOBGRAROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYUVToBGRARow = FastConvertYUVToBGRARow_SSSE3; } else #endif @@ -1475,13 +1475,13 @@ int I420ToABGR(const uint8* src_y, int src_stride_y, uint8* rgb_buf, int width); #if defined(HAS_FASTCONVERTYUVTOABGRROW_NEON) - if (TestCpuFlag(kCpuHasNEON) && (width % 16 == 0)) { + if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) { FastConvertYUVToABGRRow = FastConvertYUVToABGRRow_NEON; } else #elif defined(HAS_FASTCONVERTYUVTOABGRROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYUVToABGRRow = FastConvertYUVToABGRRow_SSSE3; } else #endif @@ -1519,8 +1519,8 @@ int I422ToARGB(const uint8* src_y, int src_stride_y, int width); #if defined(HAS_FASTCONVERTYUVTOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYUVToARGBRow = FastConvertYUVToARGBRow_SSSE3; } else #endif @@ -1556,8 +1556,8 @@ int I444ToARGB(const uint8* src_y, int src_stride_y, int width); #if defined(HAS_FASTCONVERTYUV444TOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYUV444ToARGBRow = FastConvertYUV444ToARGBRow_SSSE3; } else #endif @@ -1589,8 +1589,8 @@ int I400ToARGB_Reference(const uint8* src_y, int src_stride_y, int width); #if defined(HAS_FASTCONVERTYTOARGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { FastConvertYToARGBRow = FastConvertYToARGBRow_SSE2; } else #endif @@ -1617,9 +1617,9 @@ int I400ToARGB(const uint8* src_y, int src_stride_y, void (*I400ToARGBRow)(const uint8* src_y, uint8* dst_argb, int pix); #if defined(HAS_I400TOARGBROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 8 == 0) && - IS_ALIGNED(src_y, 8) && (src_stride_y % 8 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(src_y, 8) && IS_ALIGNED(src_stride_y, 8) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { I400ToARGBRow = I400ToARGBRow_SSE2; } else #endif @@ -1646,9 +1646,9 @@ int ABGRToARGB(const uint8* src_abgr, int src_stride_abgr, void (*ABGRToARGBRow)(const uint8* src_abgr, uint8* dst_argb, int pix); #if defined(HAS_ABGRTOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 4 == 0) && - IS_ALIGNED(src_abgr, 16) && (src_stride_abgr % 16 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 4) && + IS_ALIGNED(src_abgr, 16) && IS_ALIGNED(src_stride_abgr, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { ABGRToARGBRow = ABGRToARGBRow_SSSE3; } else #endif @@ -1676,9 +1676,9 @@ int BGRAToARGB(const uint8* src_bgra, int src_stride_bgra, void (*BGRAToARGBRow)(const uint8* src_bgra, uint8* dst_argb, int pix); #if defined(HAS_BGRATOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 4 == 0) && - IS_ALIGNED(src_bgra, 16) && (src_stride_bgra % 16 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 4) && + IS_ALIGNED(src_bgra, 16) && IS_ALIGNED(src_stride_bgra, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { BGRAToARGBRow = BGRAToARGBRow_SSSE3; } else #endif @@ -1706,9 +1706,9 @@ int ARGBToI400(const uint8* src_argb, int src_stride_argb, void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix); #if defined(HAS_ARGBTOYROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 4 == 0) && - IS_ALIGNED(src_argb, 16) && (src_stride_argb % 16 == 0) && - IS_ALIGNED(dst_y, 16) && (dst_stride_y % 16 == 0)) { + IS_ALIGNED(width, 4) && + IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) && + IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) { ARGBToYRow = ARGBToYRow_SSSE3; } else #endif @@ -1737,9 +1737,9 @@ int RAWToARGB(const uint8* src_raw, int src_stride_raw, void (*RAWToARGBRow)(const uint8* src_raw, uint8* dst_argb, int pix); #if defined(HAS_RAWTOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_raw, 16) && (src_stride_raw % 16 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_raw, 16) && IS_ALIGNED(src_stride_raw, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { RAWToARGBRow = RAWToARGBRow_SSSE3; } else #endif @@ -1767,9 +1767,9 @@ int BG24ToARGB(const uint8* src_bg24, int src_stride_bg24, void (*BG24ToARGBRow)(const uint8* src_bg24, uint8* dst_argb, int pix); #if defined(HAS_BG24TOARGBROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src_bg24, 16) && (src_stride_bg24 % 16 == 0) && - IS_ALIGNED(dst_argb, 16) && (dst_stride_argb % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src_bg24, 16) && IS_ALIGNED(src_stride_bg24, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) { BG24ToARGBRow = BG24ToARGBRow_SSSE3; } else #endif diff --git a/source/rotate.cc b/source/rotate.cc index d8faf23c2..42abc22a1 100644 --- a/source/rotate.cc +++ b/source/rotate.cc @@ -782,18 +782,18 @@ void TransposePlane(const uint8* src, int src_stride, #endif #if defined(HAS_TRANSPOSE_WX8_FAST_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && - IS_ALIGNED(dst, 8) && (dst_stride % 8 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst, 8) && IS_ALIGNED(dst_stride, 8)) { TransposeWx8 = TransposeWx8_FAST_SSSE3; TransposeWxH = TransposeWxH_C; } else #endif #if defined(HAS_TRANSPOSE_WX8_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 8 == 0) && - IS_ALIGNED(src, 8) && (src_stride % 8 == 0) && - IS_ALIGNED(dst, 8) && (dst_stride % 8 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(src, 8) && IS_ALIGNED(src_stride, 8) && + IS_ALIGNED(dst, 8) && IS_ALIGNED(dst_stride, 8)) { TransposeWx8 = TransposeWx8_SSSE3; TransposeWxH = TransposeWxH_C; } else @@ -850,9 +850,9 @@ void RotatePlane180(const uint8* src, int src_stride, #endif #if defined(HAS_REVERSE_ROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && - IS_ALIGNED(dst, 16) && (dst_stride % 16 == 0)) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst, 16) && IS_ALIGNED(dst_stride, 16)) { ReverseRow = ReverseRow_SSSE3; } else #endif @@ -926,10 +926,10 @@ void TransposeUV(const uint8* src, int src_stride, #endif #if defined(HAS_TRANSPOSE_UVWX8_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (width % 8 == 0) && - IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && - IS_ALIGNED(dst_a, 8) && (dst_stride_a % 8 == 0) && - IS_ALIGNED(dst_b, 8) && (dst_stride_b % 8 == 0)) { + IS_ALIGNED(width, 8) && + IS_ALIGNED(src, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_a, 8) && IS_ALIGNED(dst_stride_a, 8) && + IS_ALIGNED(dst_b, 8) && IS_ALIGNED(dst_stride_b, 8)) { TransposeWx8 = TransposeUVWx8_SSE2; TransposeWxH = TransposeUVWxH_C; } else @@ -1076,10 +1076,10 @@ void RotateUV180(const uint8* src, int src_stride, #endif #if defined(HAS_REVERSE_ROW_UV_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (width % 16 == 0) && - IS_ALIGNED(src, 16) && (src_stride % 16 == 0) && - IS_ALIGNED(dst_a, 8) && (dst_stride_a % 8 == 0) && - IS_ALIGNED(dst_b, 8) && (dst_stride_b % 8 == 0) ) { + IS_ALIGNED(width, 16) && + IS_ALIGNED(src, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_a, 8) && IS_ALIGNED(dst_stride_a, 8) && + IS_ALIGNED(dst_b, 8) && IS_ALIGNED(dst_stride_b, 8) ) { ReverseRow = ReverseRowUV_SSSE3; } else #endif diff --git a/source/row.h b/source/row.h index 28fb3647b..06a446334 100644 --- a/source/row.h +++ b/source/row.h @@ -14,6 +14,7 @@ #include "libyuv/basic_types.h" #define kMaxStride (2048 * 4) +#define IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) #if defined(COVERAGE_ENABLED) || defined(TARGET_IPHONE_SIMULATOR) #define YUV_DISABLE_ASM diff --git a/source/scale.cc b/source/scale.cc index 2f031685e..41979568b 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -2935,8 +2935,7 @@ static void ScaleRowDown34_0_Int_SSE2(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width) { assert((dst_width % 3 == 0) && (dst_width > 0)); ALIGN16(uint8 row[kMaxInputWidth]); - ScaleFilterRows_SSE2(row, src_ptr, src_stride, dst_width * 4 / 3, - 256 / 4); + ScaleFilterRows_SSE2(row, src_ptr, src_stride, dst_width * 4 / 3, 256 / 4); ScaleFilterCols34_C(dst_ptr, row, dst_width); } @@ -3057,22 +3056,22 @@ static void ScalePlaneDown2(int src_width, int src_height, int src_stride, int dst_stride, const uint8* src_ptr, uint8* dst_ptr, FilterMode filtering) { - assert(src_width % 2 == 0); - assert(src_height % 2 == 0); + assert(IS_ALIGNED(src_width, 2)); + assert(IS_ALIGNED(src_height, 2)); void (*ScaleRowDown2)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN2_NEON) if (TestCpuFlag(kCpuHasNEON) && - (dst_width % 16 == 0)) { + IS_ALIGNED(dst_width, 16)) { ScaleRowDown2 = filtering ? ScaleRowDown2Int_NEON : ScaleRowDown2_NEON; } else #endif #if defined(HAS_SCALEROWDOWN2_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (dst_width % 16 == 0) && - IS_ALIGNED(src_ptr, 16) && (src_stride % 16 == 0) && - IS_ALIGNED(dst_ptr, 16) && (dst_stride % 16 == 0)) { + IS_ALIGNED(dst_width, 16) && + IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_ptr, 16) && IS_ALIGNED(dst_stride, 16)) { ScaleRowDown2 = filtering ? ScaleRowDown2Int_SSE2 : ScaleRowDown2_SSE2; } else #endif @@ -3098,22 +3097,22 @@ static void ScalePlaneDown4(int src_width, int src_height, int src_stride, int dst_stride, const uint8* src_ptr, uint8* dst_ptr, FilterMode filtering) { - assert(src_width % 4 == 0); - assert(src_height % 4 == 0); + assert(IS_ALIGNED(src_width, 4)); + assert(IS_ALIGNED(src_height, 4)); void (*ScaleRowDown4)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN4_NEON) if (TestCpuFlag(kCpuHasNEON) && - (dst_width % 4 == 0)) { + IS_ALIGNED(dst_width, 4)) { ScaleRowDown4 = filtering ? ScaleRowDown4Int_NEON : ScaleRowDown4_NEON; } else #endif #if defined(HAS_SCALEROWDOWN4_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (dst_width % 8 == 0) && (src_stride % 16 == 0) && - (dst_stride % 8 == 0) && - IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { + IS_ALIGNED(dst_width, 8) && + IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_ptr, 8) && IS_ALIGNED(dst_stride, 8)) { ScaleRowDown4 = filtering ? ScaleRowDown4Int_SSE2 : ScaleRowDown4_SSE2; } else #endif @@ -3140,15 +3139,15 @@ static void ScalePlaneDown8(int src_width, int src_height, int src_stride, int dst_stride, const uint8* src_ptr, uint8* dst_ptr, FilterMode filtering) { - assert(src_width % 8 == 0); - assert(src_height % 8 == 0); + assert(IS_ALIGNED(src_width, 8)); + assert(IS_ALIGNED(src_height, 8)); void (*ScaleRowDown8)(const uint8* src_ptr, int src_stride, uint8* dst_ptr, int dst_width); #if defined(HAS_SCALEROWDOWN8_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (dst_width % 16 == 0) && dst_width <= kMaxOutputWidth && - (src_stride % 16 == 0) && (dst_stride % 16 == 0) && - IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 16)) { + IS_ALIGNED(dst_width, 4) && + IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { ScaleRowDown8 = filtering ? ScaleRowDown8Int_SSE2 : ScaleRowDown8_SSE2; } else #endif @@ -3193,9 +3192,9 @@ static void ScalePlaneDown34(int src_width, int src_height, #endif #if defined(HAS_SCALEROWDOWN34_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (dst_width % 24 == 0) && (src_stride % 16 == 0) && - (dst_stride % 8 == 0) && - IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { + (dst_width % 24 == 0) && + IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_ptr, 8) && IS_ALIGNED(dst_stride, 8)) { if (!filtering) { ScaleRowDown34_0 = ScaleRowDown34_SSSE3; ScaleRowDown34_1 = ScaleRowDown34_SSSE3; @@ -3207,8 +3206,8 @@ static void ScalePlaneDown34(int src_width, int src_height, #endif #if defined(HAS_SCALEROWDOWN34_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (dst_width % 24 == 0) && (src_stride % 16 == 0) && - (dst_stride % 8 == 0) && + (dst_width % 24 == 0) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_stride, 8) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8) && filtering) { ScaleRowDown34_0 = ScaleRowDown34_0_Int_SSE2; @@ -3282,8 +3281,8 @@ static void ScalePlaneDown38(int src_width, int src_height, #endif #if defined(HAS_SCALEROWDOWN38_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (dst_width % 24 == 0) && (src_stride % 16 == 0) && - (dst_stride % 8 == 0) && + (dst_width % 24 == 0) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_stride, 8) && IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(dst_ptr, 8)) { if (!filtering) { ScaleRowDown38_3 = ScaleRowDown38_SSSE3; @@ -3403,7 +3402,7 @@ static void ScalePlaneBox(int src_width, int src_height, assert(dst_height > 0); int dy = (src_height << 16) / dst_height; int dx = (src_width << 16) / dst_width; - if ((src_width % 16 != 0) || (src_width > kMaxInputWidth) || + if (!IS_ALIGNED(src_width, 16) || (src_width > kMaxInputWidth) || dst_height * 2 > src_height) { uint8* dst = dst_ptr; int dy = (src_height << 16) / dst_height; @@ -3431,8 +3430,8 @@ static void ScalePlaneBox(int src_width, int src_height, const uint16* src_ptr, uint8* dst_ptr); #if defined(HAS_SCALEADDROWS_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && - (src_width % 16) == 0) { + IS_ALIGNED(src_stride, 16) && IS_ALIGNED(src_ptr, 16) && + IS_ALIGNED(src_width, 16)) { ScaleAddRows = ScaleAddRows_SSE2; } else #endif @@ -3513,7 +3512,7 @@ static void ScalePlaneBilinear(int src_width, int src_height, assert(dst_height > 0); int dy = (src_height << 16) / dst_height; int dx = (src_width << 16) / dst_width; - if ((src_width % 8 != 0) || (src_width > kMaxInputWidth)) { + if (!IS_ALIGNED(src_width, 8) || (src_width > kMaxInputWidth)) { ScalePlaneBilinearSimple(src_width, src_height, dst_width, dst_height, src_stride, dst_stride, src_ptr, dst_ptr); @@ -3526,15 +3525,15 @@ static void ScalePlaneBilinear(int src_width, int src_height, int dst_width, int dx); #if defined(HAS_SCALEFILTERROWS_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && - (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && - (src_width % 16) == 0) { + IS_ALIGNED(src_stride, 16) && IS_ALIGNED(src_ptr, 16) && + IS_ALIGNED(src_width, 16)) { ScaleFilterRows = ScaleFilterRows_SSSE3; } else #endif #if defined(HAS_SCALEFILTERROWS_SSE2) if (TestCpuFlag(kCpuHasSSE2) && - (src_stride % 16 == 0) && IS_ALIGNED(src_ptr, 16) && - (src_width % 16) == 0) { + IS_ALIGNED(src_stride, 16) && IS_ALIGNED(src_ptr, 16) && + IS_ALIGNED(src_width, 16)) { ScaleFilterRows = ScaleFilterRows_SSE2; } else #endif