Fix for ARGB scaling down by 4x horizontally but not vertically

Add test ARGBScaleTo50x1_Box
libyuv_test '--gunit_filter=*ARGBScaleTo50x1*' --libyuv_width=200 --libyuv_height=50

Bug:  chromium:361611480
Change-Id: Ic984951d74eb0c377c6746f61e91593a8a7d1a66
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5884656
Reviewed-by: Wan-Teh Chang <wtc@google.com>
diff --git a/source/scale_argb.cc b/source/scale_argb.cc
index a49be39..6709c9a 100644
--- a/source/scale_argb.cc
+++ b/source/scale_argb.cc
@@ -1059,14 +1059,14 @@
     } else {
       // Optimized even scale down. ie 2, 4, 6, 8, 10x.
       if (!(dx & 0x10000) && !(dy & 0x10000)) {
-        if (dx == 0x20000) {
+        if (dx == 0x20000 && dy == 0x20000) {
           // Optimized 1/2 downsample.
           ScaleARGBDown2(src_width, src_height, clip_width, clip_height,
                          src_stride, dst_stride, src, dst, x, dx, y, dy,
                          filtering);
           return 0;
         }
-        if (dx == 0x40000 && filtering == kFilterBox) {
+        if (dx == 0x40000 && dy == 0x40000 && filtering == kFilterBox) {
           // Optimized 1/4 box downsample.
           return ScaleARGBDown4Box(src_width, src_height, clip_width,
                                    clip_height, src_stride, dst_stride, src,
diff --git a/source/scale_uv.cc b/source/scale_uv.cc
index 18ad434..5c55aab 100644
--- a/source/scale_uv.cc
+++ b/source/scale_uv.cc
@@ -1055,7 +1055,7 @@
       // Optimized even scale down. ie 2, 4, 6, 8, 10x.
       if (!(dx & 0x10000) && !(dy & 0x10000)) {
 #if HAS_SCALEUVDOWN2
-        if (dx == 0x20000) {
+        if (dx == 0x20000 && dy == 0x20000) {
           // Optimized 1/2 downsample.
           ScaleUVDown2(src_width, src_height, clip_width, clip_height,
                        src_stride, dst_stride, src, dst, x, dx, y, dy,
@@ -1064,7 +1064,7 @@
         }
 #endif
 #if HAS_SCALEUVDOWN4BOX
-        if (dx == 0x40000 && filtering == kFilterBox) {
+        if (dx == 0x40000 && dy == 0x40000 && filtering == kFilterBox) {
           // Optimized 1/4 box downsample.
           return ScaleUVDown4Box(src_width, src_height, clip_width, clip_height,
                                  src_stride, dst_stride, src, dst, x, dx, y,
diff --git a/unit_test/scale_argb_test.cc b/unit_test/scale_argb_test.cc
index 71d1bd4..8959add 100644
--- a/unit_test/scale_argb_test.cc
+++ b/unit_test/scale_argb_test.cc
@@ -323,13 +323,15 @@
 #define TEST_SCALETO(name, width, height)         \
   TEST_SCALETO1(, name, width, height, None, 0)   \
   TEST_SCALETO1(, name, width, height, Linear, 3) \
-  TEST_SCALETO1(, name, width, height, Bilinear, 3)
+  TEST_SCALETO1(, name, width, height, Bilinear, 3) \
+  TEST_SCALETO1(, name, width, height, Box, 3)
 #else
 #if defined(ENABLE_FULL_TESTS)
 #define TEST_SCALETO(name, width, height)                  \
   TEST_SCALETO1(DISABLED_, name, width, height, None, 0)   \
   TEST_SCALETO1(DISABLED_, name, width, height, Linear, 3) \
-  TEST_SCALETO1(DISABLED_, name, width, height, Bilinear, 3)
+  TEST_SCALETO1(DISABLED_, name, width, height, Bilinear, 3) \
+  TEST_SCALETO1(DISABLED_, name, width, height, Box, 3)
 #else
 #define TEST_SCALETO(name, width, height) \
   TEST_SCALETO1(DISABLED_, name, width, height, Bilinear, 3)
@@ -340,6 +342,7 @@
 TEST_SCALETO(ARGBScale, 569, 480)
 TEST_SCALETO(ARGBScale, 640, 360)
 #ifndef DISABLE_SLOW_TESTS
+TEST_SCALETO(ARGBScale, 50, 1)
 TEST_SCALETO(ARGBScale, 256, 144) /* 128x72 * 2 */
 TEST_SCALETO(ARGBScale, 320, 240)
 TEST_SCALETO(ARGBScale, 1280, 720)