Commit 748adb9001 for aom

commit 748adb90011680d10339786505a651fdb65073fb
Author: Wan-Teh Chang <wtc@google.com>
Date:   Wed Aug 12 15:43:07 2026 -0700

    Fix ref8 ptr arith. in aom_highbd_upsampled_pred_*

    Fix pointer arithmetic on ref8 in the aom_highbd_upsampled_pred_*()
    functions:
        ref8 - ref_stride * ((filter->taps >> 1) - 1)

    ref8 is a "fake" byte pointer. ref_stride should only be applied after
    ref8 is converted to a short pointer.

    This reverts to the form before commit 49bb8f8:
    https://aomedia-review.googlesource.com/c/aom/+/15342

    Because of how pointer arithmetic works on uint8_t and uint16_t
    pointers, the final pointer passed to aom_highbd_convolve8_horiz*()
    stays the same.

    Change-Id: I7230972969db901f9098205ef11d690f0cdb699a

diff --git a/av1/encoder/arm/reconinter_enc_neon.c b/av1/encoder/arm/reconinter_enc_neon.c
index e95d74f350..ac6501f74a 100644
--- a/av1/encoder/arm/reconinter_enc_neon.c
+++ b/av1/encoder/arm/reconinter_enc_neon.c
@@ -171,6 +171,7 @@ void aom_highbd_upsampled_pred_neon(MACROBLOCKD *xd,
                                    -1, kernel, 16, width, height, bd);
   } else {
     uint16_t *temp = CONVERT_TO_SHORTPTR(comp_pred8);
+    const uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
     const int16_t *const kernel_x =
         av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
     const int16_t *const kernel_y =
@@ -179,9 +180,9 @@ void aom_highbd_upsampled_pred_neon(MACROBLOCKD *xd,
         (((height - 1) * 8 + subpel_y_q3) >> 3) + filter->taps;
     assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
     aom_highbd_convolve8_horiz_neon(
-        ref8 - ref_stride * ((filter->taps >> 1) - 1), ref_stride,
-        CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL, -1, width,
-        intermediate_height, bd);
+        CONVERT_TO_BYTEPTR(ref - ref_stride * ((filter->taps >> 1) - 1)),
+        ref_stride, CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL,
+        -1, width, intermediate_height, bd);
     aom_highbd_convolve8_vert_neon(
         CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter->taps >> 1) - 1)),
         MAX_SB_SIZE, comp_pred8, width, NULL, -1, kernel_y, 16, width, height,
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c
index 95af1945fb..f169721073 100644
--- a/av1/encoder/reconinter_enc.c
+++ b/av1/encoder/reconinter_enc.c
@@ -567,6 +567,7 @@ void aom_highbd_upsampled_pred_c(MACROBLOCKD *xd,
                                 kernel, 16, width, height, bd);
   } else {
     uint16_t *temp = CONVERT_TO_SHORTPTR(comp_pred8);
+    const uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
     const int16_t *const kernel_x =
         av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
     const int16_t *const kernel_y =
@@ -574,10 +575,10 @@ void aom_highbd_upsampled_pred_c(MACROBLOCKD *xd,
     const int intermediate_height =
         (((height - 1) * 8 + subpel_y_q3) >> 3) + filter->taps;
     assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
-    aom_highbd_convolve8_horiz_c(ref8 - ref_stride * ((filter->taps >> 1) - 1),
-                                 ref_stride, CONVERT_TO_BYTEPTR(temp),
-                                 MAX_SB_SIZE, kernel_x, 16, NULL, -1, width,
-                                 intermediate_height, bd);
+    aom_highbd_convolve8_horiz_c(
+        CONVERT_TO_BYTEPTR(ref - ref_stride * ((filter->taps >> 1) - 1)),
+        ref_stride, CONVERT_TO_BYTEPTR(temp), MAX_SB_SIZE, kernel_x, 16, NULL,
+        -1, width, intermediate_height, bd);
     aom_highbd_convolve8_vert_c(
         CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter->taps >> 1) - 1)),
         MAX_SB_SIZE, comp_pred8, width, NULL, -1, kernel_y, 16, width, height,
diff --git a/av1/encoder/x86/reconinter_enc_sse2.c b/av1/encoder/x86/reconinter_enc_sse2.c
index 75c6d8d07c..e67ac1bf8f 100644
--- a/av1/encoder/x86/reconinter_enc_sse2.c
+++ b/av1/encoder/x86/reconinter_enc_sse2.c
@@ -135,7 +135,7 @@ void aom_highbd_upsampled_pred_sse2(MACROBLOCKD *xd,
   const InterpFilterParams *filter = av1_get_filter(subpel_search);
   int filter_taps = (subpel_search <= USE_4_TAPS) ? 4 : SUBPEL_TAPS;
   if (!subpel_x_q3 && !subpel_y_q3) {
-    uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
+    const uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
     uint16_t *comp_pred = CONVERT_TO_SHORTPTR(comp_pred8);
     if (width >= 8) {
       int i;
@@ -176,11 +176,12 @@ void aom_highbd_upsampled_pred_sse2(MACROBLOCKD *xd,
                               kernel, 16, width, height, bd);
   } else {
     uint16_t *temp = CONVERT_TO_SHORTPTR(comp_pred8);
+    const uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
     const int16_t *const kernel_x =
         av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
     const int16_t *const kernel_y =
         av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
-    const uint8_t *ref_start = ref8 - ref_stride * ((filter_taps >> 1) - 1);
+    const uint16_t *ref_start = ref - ref_stride * ((filter_taps >> 1) - 1);
     uint16_t *temp_start_horiz = (subpel_search <= USE_4_TAPS)
                                      ? temp + (filter_taps >> 1) * MAX_SB_SIZE
                                      : temp;
@@ -188,9 +189,10 @@ void aom_highbd_upsampled_pred_sse2(MACROBLOCKD *xd,
     const int intermediate_height =
         (((height - 1) * 8 + subpel_y_q3) >> 3) + filter_taps;
     assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
-    aom_highbd_convolve8_horiz(
-        ref_start, ref_stride, CONVERT_TO_BYTEPTR(temp_start_horiz),
-        MAX_SB_SIZE, kernel_x, 16, NULL, -1, width, intermediate_height, bd);
+    aom_highbd_convolve8_horiz(CONVERT_TO_BYTEPTR(ref_start), ref_stride,
+                               CONVERT_TO_BYTEPTR(temp_start_horiz),
+                               MAX_SB_SIZE, kernel_x, 16, NULL, -1, width,
+                               intermediate_height, bd);
     aom_highbd_convolve8_vert(CONVERT_TO_BYTEPTR(temp_start_vert), MAX_SB_SIZE,
                               comp_pred8, width, NULL, -1, kernel_y, 16, width,
                               height, bd);