Commit 5fe6dd82bc for aom

commit 5fe6dd82bc6112ccd395f0bff188796f01ed1249
Author: Wan-Teh Chang <wtc@google.com>
Date:   Tue Sep 15 11:27:28 2026 -0700

    Use correct strides in aom_compute_flow_at_point

    Use the strides corresponding to the src and ref buffers in
    aom_compute_flow_at_point. Do not use the src stride for the ref
    buffer.

    A follow-up to commit b5f92a8.

    Change-Id: Iad4b5575d30cb3c896c2d4f1aaa562c2b28335c2

diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index 5c274aaa9e..a570954bc0 100755
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -1746,7 +1746,7 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
     add_proto qw/double aom_compute_correlation/, "const unsigned char *frame1, int stride1, int x1, int y1, double mean1, double one_over_stddev1, const unsigned char *frame2, int stride2, int x2, int y2, double mean2, double one_over_stddev2";
     specialize qw/aom_compute_correlation sse4_1 avx2/;

-    add_proto qw/void aom_compute_flow_at_point/, "const uint8_t *src, const uint8_t *ref, int x, int y, int width, int height, int stride, double *u, double *v";
+    add_proto qw/void aom_compute_flow_at_point/, "const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, int x, int y, int width, int height, double *u, double *v";
     specialize qw/aom_compute_flow_at_point sse4_1 avx2 neon sve/;
   }

diff --git a/aom_dsp/flow_estimation/arm/disflow_neon.c b/aom_dsp/flow_estimation/arm/disflow_neon.c
index d6c0e0b050..5d927cdcb8 100644
--- a/aom_dsp/flow_estimation/arm/disflow_neon.c
+++ b/aom_dsp/flow_estimation/arm/disflow_neon.c
@@ -24,9 +24,10 @@
 // (x, y) in src and the other at (x + u, y + v) in ref.
 // This function returns the sum of squared pixel differences between
 // the two regions.
-static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
-                                      int width, int height, int stride, int x,
-                                      int y, double u, double v, int16_t *dt) {
+static inline void compute_flow_error(const uint8_t *src, int src_stride,
+                                      const uint8_t *ref, int ref_stride,
+                                      int width, int height, int x, int y,
+                                      double u, double v, int16_t *dt) {
   // Split offset into integer and fractional parts, and compute cubic
   // interpolation kernels
   const int u_int = (int)floor(u);
@@ -56,11 +57,11 @@ static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
   const int y0 = clamp(y + v_int, -9, height);

   // Horizontal convolution.
-  const uint8_t *ref_start = ref + (y0 - 1) * stride + (x0 - 1);
+  const uint8_t *ref_start = ref + (y0 - 1) * ref_stride + (x0 - 1);
   int16x4_t h_filter = vmovn_s32(vld1q_s32(h_kernel));

   for (int i = 0; i < DISFLOW_PATCH_SIZE + 3; ++i) {
-    uint8x16_t r = vld1q_u8(ref_start + i * stride);
+    uint8x16_t r = vld1q_u8(ref_start + i * ref_stride);
     uint16x8_t r0 = vmovl_u8(vget_low_u8(r));
     uint16x8_t r1 = vmovl_u8(vget_high_u8(r));

@@ -114,7 +115,7 @@ static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
     sum_hi = vmlal_lane_s16(sum_hi, vget_high_s16(t2), v_filter, 2);
     sum_hi = vmlal_lane_s16(sum_hi, vget_high_s16(t3), v_filter, 3);

-    uint8x8_t s = vld1_u8(src + (i + y) * stride + x);
+    uint8x8_t s = vld1_u8(src + (i + y) * src_stride + x);
     int16x8_t s_s16 = vreinterpretq_s16_u16(vshll_n_u8(s, 3));

     // This time, we have to round off the 6 extra bits which were kept
@@ -230,9 +231,10 @@ static inline void compute_flow_vector(const int16_t *dx, int dx_stride,
   vst1_s32(b, add_pairwise_s32x4(b_red));
 }

-void aom_compute_flow_at_point_neon(const uint8_t *src, const uint8_t *ref,
-                                    int x, int y, int width, int height,
-                                    int stride, double *u, double *v) {
+void aom_compute_flow_at_point_neon(const uint8_t *src, int src_stride,
+                                    const uint8_t *ref, int ref_stride, int x,
+                                    int y, int width, int height, double *u,
+                                    double *v) {
   double M_inv[4];
   int b[2];
   int16_t dt[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE];
@@ -240,14 +242,15 @@ void aom_compute_flow_at_point_neon(const uint8_t *src, const uint8_t *ref,
   int16_t dy[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE];

   // Compute gradients within this patch
-  const uint8_t *src_patch = &src[y * stride + x];
-  sobel_filter_x(src_patch, stride, dx, DISFLOW_PATCH_SIZE);
-  sobel_filter_y(src_patch, stride, dy, DISFLOW_PATCH_SIZE);
+  const uint8_t *src_patch = &src[y * src_stride + x];
+  sobel_filter_x(src_patch, src_stride, dx, DISFLOW_PATCH_SIZE);
+  sobel_filter_y(src_patch, src_stride, dy, DISFLOW_PATCH_SIZE);

   compute_flow_matrix(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, M_inv);

   for (int itr = 0; itr < DISFLOW_MAX_ITR; itr++) {
-    compute_flow_error(src, ref, width, height, stride, x, y, *u, *v, dt);
+    compute_flow_error(src, src_stride, ref, ref_stride, width, height, x, y,
+                       *u, *v, dt);
     compute_flow_vector(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, dt,
                         DISFLOW_PATCH_SIZE, b);

diff --git a/aom_dsp/flow_estimation/arm/disflow_sve.c b/aom_dsp/flow_estimation/arm/disflow_sve.c
index c2160a02a9..a8a912d9e9 100644
--- a/aom_dsp/flow_estimation/arm/disflow_sve.c
+++ b/aom_dsp/flow_estimation/arm/disflow_sve.c
@@ -30,9 +30,10 @@ DECLARE_ALIGNED(16, static const uint16_t, kDeinterleaveTbl[8]) = {
 // (x, y) in src and the other at (x + u, y + v) in ref.
 // This function returns the sum of squared pixel differences between
 // the two regions.
-static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
-                                      int width, int height, int stride, int x,
-                                      int y, double u, double v, int16_t *dt) {
+static inline void compute_flow_error(const uint8_t *src, int src_stride,
+                                      const uint8_t *ref, int ref_stride,
+                                      int width, int height, int x, int y,
+                                      double u, double v, int16_t *dt) {
   // Split offset into integer and fractional parts, and compute cubic
   // interpolation kernels
   const int u_int = (int)floor(u);
@@ -62,16 +63,16 @@ static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
   const int y0 = clamp(y + v_int, -9, height);

   // Horizontal convolution.
-  const uint8_t *ref_start = ref + (y0 - 1) * stride + (x0 - 1);
+  const uint8_t *ref_start = ref + (y0 - 1) * ref_stride + (x0 - 1);
   const int16x4_t h_kernel_s16 = vmovn_s32(vld1q_s32(h_kernel));
   const int16x8_t h_filter = vcombine_s16(h_kernel_s16, vdup_n_s16(0));
   const uint16x8_t idx = vld1q_u16(kDeinterleaveTbl);

   for (int i = 0; i < DISFLOW_PATCH_SIZE + 3; ++i) {
-    svuint16_t r0 = svld1ub_u16(svptrue_b16(), ref_start + i * stride + 0);
-    svuint16_t r1 = svld1ub_u16(svptrue_b16(), ref_start + i * stride + 1);
-    svuint16_t r2 = svld1ub_u16(svptrue_b16(), ref_start + i * stride + 2);
-    svuint16_t r3 = svld1ub_u16(svptrue_b16(), ref_start + i * stride + 3);
+    svuint16_t r0 = svld1ub_u16(svptrue_b16(), ref_start + i * ref_stride + 0);
+    svuint16_t r1 = svld1ub_u16(svptrue_b16(), ref_start + i * ref_stride + 1);
+    svuint16_t r2 = svld1ub_u16(svptrue_b16(), ref_start + i * ref_stride + 2);
+    svuint16_t r3 = svld1ub_u16(svptrue_b16(), ref_start + i * ref_stride + 3);

     int16x8_t s0 = vreinterpretq_s16_u16(svget_neonq_u16(r0));
     int16x8_t s1 = vreinterpretq_s16_u16(svget_neonq_u16(r1));
@@ -123,7 +124,7 @@ static inline void compute_flow_error(const uint8_t *src, const uint8_t *ref,
     sum_hi = vmlal_lane_s16(sum_hi, vget_high_s16(t2), v_filter, 2);
     sum_hi = vmlal_lane_s16(sum_hi, vget_high_s16(t3), v_filter, 3);

-    uint8x8_t s = vld1_u8(src + (i + y) * stride + x);
+    uint8x8_t s = vld1_u8(src + (i + y) * src_stride + x);
     int16x8_t s_s16 = vreinterpretq_s16_u16(vshll_n_u8(s, 3));

     // This time, we have to round off the 6 extra bits which were kept
@@ -232,9 +233,10 @@ static inline void compute_flow_vector(const int16_t *dx, int dx_stride,
   vst1_s32(b, vmovn_s64(b_s64[0]));
 }

-void aom_compute_flow_at_point_sve(const uint8_t *src, const uint8_t *ref,
-                                   int x, int y, int width, int height,
-                                   int stride, double *u, double *v) {
+void aom_compute_flow_at_point_sve(const uint8_t *src, int src_stride,
+                                   const uint8_t *ref, int ref_stride, int x,
+                                   int y, int width, int height, double *u,
+                                   double *v) {
   double M_inv[4];
   int b[2];
   int16_t dt[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE];
@@ -242,14 +244,15 @@ void aom_compute_flow_at_point_sve(const uint8_t *src, const uint8_t *ref,
   int16_t dy[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE];

   // Compute gradients within this patch
-  const uint8_t *src_patch = &src[y * stride + x];
-  sobel_filter_x(src_patch, stride, dx, DISFLOW_PATCH_SIZE);
-  sobel_filter_y(src_patch, stride, dy, DISFLOW_PATCH_SIZE);
+  const uint8_t *src_patch = &src[y * src_stride + x];
+  sobel_filter_x(src_patch, src_stride, dx, DISFLOW_PATCH_SIZE);
+  sobel_filter_y(src_patch, src_stride, dy, DISFLOW_PATCH_SIZE);

   compute_flow_matrix(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, M_inv);

   for (int itr = 0; itr < DISFLOW_MAX_ITR; itr++) {
-    compute_flow_error(src, ref, width, height, stride, x, y, *u, *v, dt);
+    compute_flow_error(src, src_stride, ref, ref_stride, width, height, x, y,
+                       *u, *v, dt);
     compute_flow_vector(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, dt,
                         DISFLOW_PATCH_SIZE, b);

diff --git a/aom_dsp/flow_estimation/corner_match.c b/aom_dsp/flow_estimation/corner_match.c
index 7a00e1fdfc..72b65b36b6 100644
--- a/aom_dsp/flow_estimation/corner_match.c
+++ b/aom_dsp/flow_estimation/corner_match.c
@@ -118,12 +118,11 @@ typedef struct {
   double best_match_corr;
 } PointInfo;

-static int determine_correspondence(const unsigned char *src,
+static int determine_correspondence(const unsigned char *src, int src_stride,
                                     const int *src_corners, int num_src_corners,
-                                    const unsigned char *ref,
+                                    const unsigned char *ref, int ref_stride,
                                     const int *ref_corners, int num_ref_corners,
-                                    int width, int height, int src_stride,
-                                    int ref_stride,
+                                    int width, int height,
                                     Correspondence *correspondences) {
   PointInfo *src_point_info = NULL;
   PointInfo *ref_point_info = NULL;
@@ -233,8 +232,8 @@ static int determine_correspondence(const unsigned char *src,
       const int patch_tl_x = sx - DISFLOW_PATCH_CENTER;
       const int patch_tl_y = sy - DISFLOW_PATCH_CENTER;

-      aom_compute_flow_at_point(src, ref, patch_tl_x, patch_tl_y, width, height,
-                                src_stride, &u, &v);
+      aom_compute_flow_at_point(src, src_stride, ref, ref_stride, patch_tl_x,
+                                patch_tl_y, width, height, &u, &v);

       Correspondence *correspondence = &correspondences[num_correspondences];
       correspondence->x = (double)sx;
@@ -303,9 +302,9 @@ bool av1_compute_global_motion_feature_match(
     return false;
   }
   num_correspondences = determine_correspondence(
-      src_buffer, src_corners->corners, src_corners->num_corners, ref_buffer,
-      ref_corners->corners, ref_corners->num_corners, src_width, src_height,
-      src_stride, ref_stride, correspondences);
+      src_buffer, src_stride, src_corners->corners, src_corners->num_corners,
+      ref_buffer, ref_stride, ref_corners->corners, ref_corners->num_corners,
+      src_width, src_height, correspondences);

   bool result = ransac(correspondences, num_correspondences, type,
                        motion_models, num_motion_models, mem_alloc_failed);
diff --git a/aom_dsp/flow_estimation/disflow.c b/aom_dsp/flow_estimation/disflow.c
index cb044ba57e..22d1d44631 100644
--- a/aom_dsp/flow_estimation/disflow.c
+++ b/aom_dsp/flow_estimation/disflow.c
@@ -172,9 +172,10 @@ static int determine_disflow_correspondence(const ImagePyramid *src_pyr,
     const int patch_tl_x = x0 - DISFLOW_PATCH_CENTER;
     const int patch_tl_y = y0 - DISFLOW_PATCH_CENTER;
     aom_compute_flow_at_point(
-        src_pyr->layers[0].buffer, ref_pyr->layers[0].buffer, patch_tl_x,
+        src_pyr->layers[0].buffer, src_pyr->layers[0].stride,
+        ref_pyr->layers[0].buffer, ref_pyr->layers[0].stride, patch_tl_x,
         patch_tl_y, src_pyr->layers[0].width, src_pyr->layers[0].height,
-        src_pyr->layers[0].stride, &flow_u, &flow_v);
+        &flow_u, &flow_v);

     // Use original points (without offsets) when filling in correspondence
     // array
@@ -191,11 +192,11 @@ static int determine_disflow_correspondence(const ImagePyramid *src_pyr,
 // (x, y) in src and the other at (x + u, y + v) in ref.
 // This function returns the sum of squared pixel differences between
 // the two regions.
-static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
-                                       int width, int height, int stride, int x,
-                                       int y, double u, double v,
-                                       const int16_t *dx, const int16_t *dy,
-                                       int *b) {
+static inline void compute_flow_vector(const uint8_t *src, int src_stride,
+                                       const uint8_t *ref, int ref_stride,
+                                       int width, int height, int x, int y,
+                                       double u, double v, const int16_t *dx,
+                                       const int16_t *dy, int *b) {
   memset(b, 0, 2 * sizeof(*b));

   // Split offset into integer and fractional parts, and compute cubic
@@ -235,10 +236,10 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
       const int x_w = x0 + j;
       int arr[4];

-      arr[0] = (int)ref[y_w * stride + (x_w - 1)];
-      arr[1] = (int)ref[y_w * stride + (x_w + 0)];
-      arr[2] = (int)ref[y_w * stride + (x_w + 1)];
-      arr[3] = (int)ref[y_w * stride + (x_w + 2)];
+      arr[0] = (int)ref[y_w * ref_stride + (x_w - 1)];
+      arr[1] = (int)ref[y_w * ref_stride + (x_w + 0)];
+      arr[2] = (int)ref[y_w * ref_stride + (x_w + 1)];
+      arr[3] = (int)ref[y_w * ref_stride + (x_w + 2)];

       // Apply kernel and round, keeping 6 extra bits of precision.
       //
@@ -270,7 +271,7 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
       // of precision to match the scale of the dx and dy arrays.
       const int round_bits = DISFLOW_INTERP_BITS + 6 - DISFLOW_DERIV_SCALE_LOG2;
       const int warped = ROUND_POWER_OF_TWO(result, round_bits);
-      const int src_px = src[(x + j) + (y + i) * stride] << 3;
+      const int src_px = src[(x + j) + (y + i) * src_stride] << 3;
       const int dt = warped - src_px;
       b[0] += dx[i * DISFLOW_PATCH_SIZE + j] * dt;
       b[1] += dy[i * DISFLOW_PATCH_SIZE + j] * dt;
@@ -410,9 +411,10 @@ static inline void invert_2x2(const double *M, double *M_inv) {
   M_inv[3] = M[0] * det_inv;
 }

-void aom_compute_flow_at_point_c(const uint8_t *src, const uint8_t *ref, int x,
-                                 int y, int width, int height, int stride,
-                                 double *u, double *v) {
+void aom_compute_flow_at_point_c(const uint8_t *src, int src_stride,
+                                 const uint8_t *ref, int ref_stride, int x,
+                                 int y, int width, int height, double *u,
+                                 double *v) {
   double M[4];
   double M_inv[4];
   int b[2];
@@ -420,16 +422,16 @@ void aom_compute_flow_at_point_c(const uint8_t *src, const uint8_t *ref, int x,
   int16_t dy[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE];

   // Compute gradients within this patch
-  const uint8_t *src_patch = &src[y * stride + x];
-  sobel_filter(src_patch, stride, dx, DISFLOW_PATCH_SIZE, 1);
-  sobel_filter(src_patch, stride, dy, DISFLOW_PATCH_SIZE, 0);
+  const uint8_t *src_patch = &src[y * src_stride + x];
+  sobel_filter(src_patch, src_stride, dx, DISFLOW_PATCH_SIZE, 1);
+  sobel_filter(src_patch, src_stride, dy, DISFLOW_PATCH_SIZE, 0);

   compute_flow_matrix(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, M);
   invert_2x2(M, M_inv);

   for (int itr = 0; itr < DISFLOW_MAX_ITR; itr++) {
-    compute_flow_vector(src, ref, width, height, stride, x, y, *u, *v, dx, dy,
-                        b);
+    compute_flow_vector(src, src_stride, ref, ref_stride, width, height, x, y,
+                        *u, *v, dx, dy, b);

     // Solve flow equations to find a better estimate for the flow vector
     // at this point
@@ -650,10 +652,11 @@ static bool compute_flow_field(const ImagePyramid *src_pyr,
     const PyramidLayer *cur_layer = &src_pyr->layers[level];
     const int cur_width = cur_layer->width;
     const int cur_height = cur_layer->height;
-    const int cur_stride = cur_layer->stride;

     const uint8_t *src_buffer = cur_layer->buffer;
+    const int src_stride = cur_layer->stride;
     const uint8_t *ref_buffer = ref_pyr->layers[level].buffer;
+    const int ref_stride = ref_pyr->layers[level].stride;

     const int cur_flow_width = cur_width >> DOWNSAMPLE_SHIFT;
     const int cur_flow_height = cur_height >> DOWNSAMPLE_SHIFT;
@@ -676,9 +679,9 @@ static bool compute_flow_field(const ImagePyramid *src_pyr,
         assert(patch_tl_x >= 0);
         assert(patch_tl_y >= 0);

-        aom_compute_flow_at_point(src_buffer, ref_buffer, patch_tl_x,
-                                  patch_tl_y, cur_width, cur_height, cur_stride,
-                                  &flow_u[flow_field_idx],
+        aom_compute_flow_at_point(src_buffer, src_stride, ref_buffer,
+                                  ref_stride, patch_tl_x, patch_tl_y, cur_width,
+                                  cur_height, &flow_u[flow_field_idx],
                                   &flow_v[flow_field_idx]);
       }
     }
diff --git a/aom_dsp/flow_estimation/x86/disflow_avx2.c b/aom_dsp/flow_estimation/x86/disflow_avx2.c
index b93acdd418..d1d1969b69 100644
--- a/aom_dsp/flow_estimation/x86/disflow_avx2.c
+++ b/aom_dsp/flow_estimation/x86/disflow_avx2.c
@@ -81,11 +81,11 @@ static inline __m128i compute_cubic_kernels(double u, double v) {
 //
 // TODO(rachelbarker): Test speed/quality impact of using bilinear interpolation
 // instad of bicubic interpolation
-static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
-                                       int width, int height, int stride, int x,
-                                       int y, double u, double v,
-                                       const int16_t *dx, const int16_t *dy,
-                                       int *b) {
+static inline void compute_flow_vector(const uint8_t *src, int src_stride,
+                                       const uint8_t *ref, int ref_stride,
+                                       int width, int height, int x, int y,
+                                       double u, double v, const int16_t *dx,
+                                       const int16_t *dy, int *b) {
   const __m256i zero = _mm256_setzero_si256();

   // Accumulate 8 32-bit partial sums for each element of b
@@ -137,7 +137,7 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,

   for (int i = -1; i < DISFLOW_PATCH_SIZE + 2; i += 2) {
     const int y_w = y0 + i;
-    const uint8_t *ref_row = &ref[y_w * stride + (x0 - 1)];
+    const uint8_t *ref_row = &ref[y_w * ref_stride + (x0 - 1)];
     int16_t *tmp_row = &tmp[i * DISFLOW_PATCH_SIZE];

     // Load this row of pixels.
@@ -145,7 +145,7 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
     // for a total of 11 pixels. Here we load 16 pixels, but only use
     // the first 11.
     __m256i row =
-        yy_loadu2_128((__m128i *)(ref_row + stride), (__m128i *)ref_row);
+        yy_loadu2_128((__m128i *)(ref_row + ref_stride), (__m128i *)ref_row);

     // Expand pixels to int16s
     // We must use unpacks here, as we have one row in each 128-bit lane
@@ -234,8 +234,8 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
         _mm256_srai_epi32(_mm256_add_epi32(sum1, round_const_v), round_bits);

     __m256i warped = _mm256_packs_epi32(sum0_rounded, sum1_rounded);
-    __m128i src_pixels_u8 = xx_loadu_2x64(&src[(y + i + 1) * stride + x],
-                                          &src[(y + i) * stride + x]);
+    __m128i src_pixels_u8 = xx_loadu_2x64(&src[(y + i + 1) * src_stride + x],
+                                          &src[(y + i) * src_stride + x]);
     __m256i src_pixels =
         _mm256_slli_epi16(_mm256_cvtepu8_epi16(src_pixels_u8), 3);

@@ -382,9 +382,10 @@ static inline void invert_2x2(const double *M, double *M_inv) {
   M_inv[3] = M[0] * det_inv;
 }

-void aom_compute_flow_at_point_avx2(const uint8_t *src, const uint8_t *ref,
-                                    int x, int y, int width, int height,
-                                    int stride, double *u, double *v) {
+void aom_compute_flow_at_point_avx2(const uint8_t *src, int src_stride,
+                                    const uint8_t *ref, int ref_stride, int x,
+                                    int y, int width, int height, double *u,
+                                    double *v) {
   DECLARE_ALIGNED(32, double, M[4]);
   DECLARE_ALIGNED(32, double, M_inv[4]);
   DECLARE_ALIGNED(32, int16_t, dx[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE]);
@@ -392,15 +393,15 @@ void aom_compute_flow_at_point_avx2(const uint8_t *src, const uint8_t *ref,
   int b[2];

   // Compute gradients within this patch
-  const uint8_t *src_patch = &src[y * stride + x];
-  sobel_filter(src_patch, stride, dx, dy);
+  const uint8_t *src_patch = &src[y * src_stride + x];
+  sobel_filter(src_patch, src_stride, dx, dy);

   compute_flow_matrix(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, M);
   invert_2x2(M, M_inv);

   for (int itr = 0; itr < DISFLOW_MAX_ITR; itr++) {
-    compute_flow_vector(src, ref, width, height, stride, x, y, *u, *v, dx, dy,
-                        b);
+    compute_flow_vector(src, src_stride, ref, ref_stride, width, height, x, y,
+                        *u, *v, dx, dy, b);

     // Solve flow equations to find a better estimate for the flow vector
     // at this point
diff --git a/aom_dsp/flow_estimation/x86/disflow_sse4.c b/aom_dsp/flow_estimation/x86/disflow_sse4.c
index ffbe4858b5..2d01315b64 100644
--- a/aom_dsp/flow_estimation/x86/disflow_sse4.c
+++ b/aom_dsp/flow_estimation/x86/disflow_sse4.c
@@ -80,11 +80,11 @@ static inline __m128i compute_cubic_kernels(double u, double v) {
 //
 // TODO(rachelbarker): Test speed/quality impact of using bilinear interpolation
 // instad of bicubic interpolation
-static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,
-                                       int width, int height, int stride, int x,
-                                       int y, double u, double v,
-                                       const int16_t *dx, const int16_t *dy,
-                                       int *b) {
+static inline void compute_flow_vector(const uint8_t *src, int src_stride,
+                                       const uint8_t *ref, int ref_stride,
+                                       int width, int height, int x, int y,
+                                       double u, double v, const int16_t *dx,
+                                       const int16_t *dy, int *b) {
   // This function is written to do 8x8 convolutions only
   assert(DISFLOW_PATCH_SIZE == 8);

@@ -134,7 +134,7 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,

   for (int i = -1; i < DISFLOW_PATCH_SIZE + 2; ++i) {
     const int y_w = y0 + i;
-    const uint8_t *ref_row = &ref[y_w * stride + (x0 - 1)];
+    const uint8_t *ref_row = &ref[y_w * ref_stride + (x0 - 1)];
     int16_t *tmp_row = &tmp[i * DISFLOW_PATCH_SIZE];

     // Load this row of pixels.
@@ -218,7 +218,7 @@ static inline void compute_flow_vector(const uint8_t *src, const uint8_t *ref,

     __m128i warped = _mm_packs_epi32(sum0_rounded, sum1_rounded);
     __m128i src_pixels_u8 =
-        _mm_loadl_epi64((__m128i *)&src[(y + i) * stride + x]);
+        _mm_loadl_epi64((__m128i *)&src[(y + i) * src_stride + x]);
     __m128i src_pixels = _mm_slli_epi16(_mm_cvtepu8_epi16(src_pixels_u8), 3);

     // Calculate delta from the target patch
@@ -357,9 +357,10 @@ static inline void invert_2x2(const double *M, double *M_inv) {
   M_inv[3] = M[0] * det_inv;
 }

-void aom_compute_flow_at_point_sse4_1(const uint8_t *src, const uint8_t *ref,
-                                      int x, int y, int width, int height,
-                                      int stride, double *u, double *v) {
+void aom_compute_flow_at_point_sse4_1(const uint8_t *src, int src_stride,
+                                      const uint8_t *ref, int ref_stride, int x,
+                                      int y, int width, int height, double *u,
+                                      double *v) {
   DECLARE_ALIGNED(16, double, M[4]);
   DECLARE_ALIGNED(16, double, M_inv[4]);
   DECLARE_ALIGNED(16, int16_t, dx[DISFLOW_PATCH_SIZE * DISFLOW_PATCH_SIZE]);
@@ -367,15 +368,15 @@ void aom_compute_flow_at_point_sse4_1(const uint8_t *src, const uint8_t *ref,
   int b[2];

   // Compute gradients within this patch
-  const uint8_t *src_patch = &src[y * stride + x];
-  sobel_filter(src_patch, stride, dx, dy);
+  const uint8_t *src_patch = &src[y * src_stride + x];
+  sobel_filter(src_patch, src_stride, dx, dy);

   compute_flow_matrix(dx, DISFLOW_PATCH_SIZE, dy, DISFLOW_PATCH_SIZE, M);
   invert_2x2(M, M_inv);

   for (int itr = 0; itr < DISFLOW_MAX_ITR; itr++) {
-    compute_flow_vector(src, ref, width, height, stride, x, y, *u, *v, dx, dy,
-                        b);
+    compute_flow_vector(src, src_stride, ref, ref_stride, width, height, x, y,
+                        *u, *v, dx, dy, b);

     // Solve flow equations to find a better estimate for the flow vector
     // at this point
diff --git a/test/disflow_test.cc b/test/disflow_test.cc
index 61226b59da..78f9565912 100644
--- a/test/disflow_test.cc
+++ b/test/disflow_test.cc
@@ -22,9 +22,10 @@

 namespace {

-using ComputeFlowAtPointFunc = void (*)(const uint8_t *src, const uint8_t *ref,
+using ComputeFlowAtPointFunc = void (*)(const uint8_t *src, int src_stride,
+                                        const uint8_t *ref, int ref_stride,
                                         int x, int y, int width, int height,
-                                        int stride, double *u, double *v);
+                                        double *u, double *v);

 class ComputeFlowTest
     : public ::testing::TestWithParam<ComputeFlowAtPointFunc> {
@@ -75,16 +76,17 @@ void ComputeFlowTest::RunCheckOutput(int run_times) {

   aom_usec_timer ref_timer, test_timer;

-  aom_compute_flow_at_point_c(src, ref, x, y, kWidth, kHeight, kWidth, &u_ref,
-                              &v_ref);
+  aom_compute_flow_at_point_c(src, kWidth, ref, kWidth, x, y, kWidth, kHeight,
+                              &u_ref, &v_ref);

-  target_func_(src, ref, x, y, kWidth, kHeight, kWidth, &u_test, &v_test);
+  target_func_(src, kWidth, ref, kWidth, x, y, kWidth, kHeight, &u_test,
+               &v_test);

   if (run_times > 1) {
     aom_usec_timer_start(&ref_timer);
     for (int i = 0; i < run_times; ++i) {
-      aom_compute_flow_at_point_c(src, ref, x, y, kWidth, kHeight, kWidth,
-                                  &u_ref, &v_ref);
+      aom_compute_flow_at_point_c(src, kWidth, ref, kWidth, x, y, kWidth,
+                                  kHeight, &u_ref, &v_ref);
     }
     aom_usec_timer_mark(&ref_timer);
     const double elapsed_time_c =
@@ -92,7 +94,8 @@ void ComputeFlowTest::RunCheckOutput(int run_times) {

     aom_usec_timer_start(&test_timer);
     for (int i = 0; i < run_times; ++i) {
-      target_func_(src, ref, x, y, kWidth, kHeight, kWidth, &u_test, &v_test);
+      target_func_(src, kWidth, ref, kWidth, x, y, kWidth, kHeight, &u_test,
+                   &v_test);
     }
     aom_usec_timer_mark(&test_timer);
     const double elapsed_time_simd =