Resize/Superres: clamp resized width/height to 16.

This is to ensure the constraint in "Appendix A" of the spec:
* FrameWidth is greater than or equal to 16
* FrameHeight is greater than or equal to 16

As clarified here:
https://jointdevelopment.kavi.com/higherlogic/ws/groups/aomediacodec/discussions/9320
"constraint is intended for the final (potentially smaller) values for each
FrameWidth/FrameHeight."

So, it applies to both resize and superres.

BUG=aomedia:2102

Change-Id: I8014ba1ae0fd0aad49738187102a89d1e94f060e
diff --git a/av1/common/resize.c b/av1/common/resize.c
index d61a20a..6bb360c 100644
--- a/av1/common/resize.c
+++ b/av1/common/resize.c
@@ -1155,10 +1155,19 @@
 // denominator.
 static void calculate_scaled_size_helper(int *dim, int denom) {
   if (denom != SCALE_NUMERATOR) {
+    // We need to ensure the constraint in "Appendix A" of the spec:
+    // * FrameWidth is greater than or equal to 16
+    // * FrameHeight is greater than or equal to 16
+    // For this, we clamp the downscaled dimension to at least 16. One
+    // exception: if original dimension itself was < 16, then we keep the
+    // downscaled dimension to be same as the original, to ensure that resizing
+    // is valid.
+    const int min_dim = AOMMIN(16, *dim);
     // Use this version if we need *dim to be even
     // *width = (*width * SCALE_NUMERATOR + denom) / (2 * denom);
     // *width <<= 1;
     *dim = (*dim * SCALE_NUMERATOR + denom / 2) / (denom);
+    *dim = AOMMAX(*dim, min_dim);
   }
 }