aom: Apply stride_align to byte count, not pixel count

From a38ab61907e7619c6b100a769284505959def53e Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Mon, 8 Apr 2024 19:00:12 -0700
Subject: [PATCH] Apply stride_align to byte count, not pixel count

stride_align is documented to be the "alignment, in bytes, of each row
in the image (stride)."

Change-Id: I4663f2fdf264800a0b8441772749920780248fbe
---
 aom/src/aom_image.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/aom/src/aom_image.c b/aom/src/aom_image.c
index e10b8a9ad..09b6dd408 100644
--- a/aom/src/aom_image.c
+++ b/aom/src/aom_image.c
@@ -119,8 +119,9 @@ static aom_image_t *img_alloc_helper(
   assert(d_h <= h);
 
   uint64_t s = (fmt & AOM_IMG_FMT_PLANAR) ? w : (uint64_t)bps * w / bit_depth;
-  s = (s + 2 * border + stride_align - 1) & ~((uint64_t)stride_align - 1);
+  s = s + 2 * border;
   s = s * bit_depth / 8;
+  s = (s + stride_align - 1) & ~((uint64_t)stride_align - 1);
   if (s > INT_MAX) goto fail;
   const int stride_in_bytes = (int)s;