diff --git a/libswscale/utils.c b/libswscale/utils.c
index a3fa25a910d05d751cf6d074a5b63a650055653a..8fd0ab6921e68f0530c77da8326b4c6b4644ecf4 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -386,7 +386,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
 
         xDstInSrc = ((dstPos*(int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);
         for (i = 0; i < dstW; i++) {
-            int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17);
+            int xx = (xDstInSrc - (filterSize - 2) * (1LL<<16)) / (1 << 17);
             int j;
             (*filterPos)[i] = xx;
             for (j = 0; j < filterSize; j++) {