From bd0c18d85c0db66e336893938d34ce04559091f9 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 18 Nov 2024 19:02:58 +0100 Subject: [PATCH] Remove redundant `lskip` variable --- libvips/resample/presample.h | 4 ++-- libvips/resample/reducev.cpp | 3 +-- libvips/resample/reducev_hwy.cpp | 20 +++++++++----------- libvips/resample/shrinkv.c | 4 +--- libvips/resample/shrinkv_hwy.cpp | 21 +++++++++------------ 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/libvips/resample/presample.h b/libvips/resample/presample.h index 56c436e9f..152053ed2 100644 --- a/libvips/resample/presample.h +++ b/libvips/resample/presample.h @@ -76,12 +76,12 @@ void vips_reduceh_uchar_hwy(VipsPel *pout, VipsPel *pin, short *restrict cs[VIPS_TRANSFORM_SCALE + 1], double X, double hshrink); void vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, - int n, int ne, int lskip, const short *restrict k); + int n, int ne, const short *restrict k); void vips_shrinkh_uchar_hwy(VipsPel *pout, VipsPel *pin, int width, int hshrink, int bands); void vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, - int ne, int vshrink, int lskip); + int ne, int vshrink); #ifdef __cplusplus } diff --git a/libvips/resample/reducev.cpp b/libvips/resample/reducev.cpp index 3cc3f6fbb..32828ddc5 100644 --- a/libvips/resample/reducev.cpp +++ b/libvips/resample/reducev.cpp @@ -623,11 +623,10 @@ vips_reducev_uchar_vector_gen(VipsRegion *out_region, void *vseq, const int siy = sy & (VIPS_TRANSFORM_SCALE * 2 - 1); const int ty = (siy + 1) >> 1; const short *cys = reducev->matrixs[ty]; - const int lskip = VIPS_REGION_LSKIP(ir); vips_reducev_uchar_hwy( q, p, - reducev->n_point, ne, lskip, cys); + reducev->n_point, ne, cys); Y += reducev->vshrink; } diff --git a/libvips/resample/reducev_hwy.cpp b/libvips/resample/reducev_hwy.cpp index 663de03a3..bda499368 100644 --- a/libvips/resample/reducev_hwy.cpp +++ b/libvips/resample/reducev_hwy.cpp @@ -79,11 +79,9 @@ constexpr DI32 di32; HWY_ATTR void vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, - int32_t n, int32_t ne, int32_t lskip, const int16_t *HWY_RESTRICT k) + int32_t n, int32_t ne, const int16_t *HWY_RESTRICT k) { #if HWY_TARGET != HWY_SCALAR - const auto l1 = lskip / sizeof(uint8_t); - #if !defined(HAVE_HWY_1_1_0) && \ (HWY_ARCH_RVV || (HWY_ARCH_ARM_A64 && HWY_TARGET <= HWY_SVE)) /* Ensure we do not cross 128-bit block boundaries on RVV/SVE. @@ -130,9 +128,9 @@ vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, auto mmk = BitCast(di16, Set(di32, *(int32_t *) &k[i])); auto top = LoadU(du8, p); /* top line */ - p += l1; + p += ne; auto bottom = LoadU(du8, p); /* bottom line */ - p += l1; + p += ne; auto source = InterleaveLower(top, bottom); auto pix = BitCast(di16, InterleaveLower(source, zero)); @@ -160,7 +158,7 @@ vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, auto mmk = Set(di16, k[i]); auto top = LoadU(du8, p); - p += l1; + p += ne; auto source = InterleaveLower(top, zero); auto pix = BitCast(di16, InterleaveLower(source, zero)); @@ -251,9 +249,9 @@ vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, auto mmk = BitCast(di16, Set(di32, *(int32_t *) &k[i])); auto top = LoadU(du8x16, p); /* top line */ - p += l1; + p += ne; auto bottom = LoadU(du8x16, p); /* bottom line */ - p += l1; + p += ne; auto source = InterleaveLower(top, bottom); auto pix = PromoteTo(di16, source); @@ -265,7 +263,7 @@ vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, auto mmk = Set(di16, k[i]); auto top = LoadU(du8x32, p); - p += l1; + p += ne; auto source = PromoteTo(di32, top); auto pix = BitCast(di16, source); @@ -300,10 +298,10 @@ HWY_EXPORT(vips_reducev_uchar_hwy); void vips_reducev_uchar_hwy(VipsPel *pout, VipsPel *pin, - int n, int ne, int lskip, const short *restrict k) + int n, int ne, const short *restrict k) { /* clang-format off */ - HWY_DYNAMIC_DISPATCH(vips_reducev_uchar_hwy)(pout, pin, n, ne, lskip, k); + HWY_DYNAMIC_DISPATCH(vips_reducev_uchar_hwy)(pout, pin, n, ne, k); /* clang-format on */ } #endif /*HWY_ONCE*/ diff --git a/libvips/resample/shrinkv.c b/libvips/resample/shrinkv.c index fe9fb65be..fc6db0600 100644 --- a/libvips/resample/shrinkv.c +++ b/libvips/resample/shrinkv.c @@ -343,8 +343,6 @@ vips_shrinkv_uchar_vector_gen(VipsRegion *out_region, VIPS_GATE_START("vips_shrinkv_uchar_vector_gen: work"); - const int lskip = VIPS_REGION_LSKIP(ir); - // each output line for (y1 = 0; y1 < chunk_height; y1++) { // top of this line in the input @@ -353,7 +351,7 @@ vips_shrinkv_uchar_vector_gen(VipsRegion *out_region, VipsPel *q = VIPS_REGION_ADDR(out_region, r->left, r->top + y + y1); VipsPel *p = VIPS_REGION_ADDR(ir, s.left, top); - vips_shrinkv_uchar_hwy(q, p, ne, shrink->vshrink, lskip); + vips_shrinkv_uchar_hwy(q, p, ne, shrink->vshrink); } VIPS_GATE_STOP("vips_shrinkv_uchar_vector_gen: work"); diff --git a/libvips/resample/shrinkv_hwy.cpp b/libvips/resample/shrinkv_hwy.cpp index 9553c83e2..d9b1f26ae 100644 --- a/libvips/resample/shrinkv_hwy.cpp +++ b/libvips/resample/shrinkv_hwy.cpp @@ -74,11 +74,9 @@ constexpr float maxBits = 1 << 8; HWY_ATTR void vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, - int32_t ne, int32_t vshrink, int32_t lskip) + int32_t ne, int32_t vshrink) { #if HWY_TARGET != HWY_SCALAR - const auto l1 = lskip / sizeof(uint8_t); - #if !defined(HAVE_HWY_1_1_0) && \ (HWY_ARCH_RVV || (HWY_ARCH_ARM_A64 && HWY_TARGET <= HWY_SVE)) /* Ensure we do not cross 128-bit block boundaries on RVV/SVE. @@ -106,9 +104,9 @@ vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, int32_t yy = 0; for (; yy + 2 <= vshrink; yy += 2) { auto pix0 = PromoteTo(du16, LoadU(du8x16, p)); - p += l1; + p += ne; auto pix1 = PromoteTo(du16, LoadU(du8x16, p)); - p += l1; + p += ne; pix0 = Add(pix0, pix1); @@ -117,7 +115,7 @@ vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, } for (; yy < vshrink; ++yy) { auto pix0 = PromoteTo(du16, LoadU(du8x16, p)); - p += l1; + p += ne; sum0 = Add(sum0, BitCast(du32, InterleaveLower(du16, pix0, zero))); sum1 = Add(sum1, BitCast(du32, InterleaveUpper(du16, pix0, zero))); @@ -160,16 +158,16 @@ vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, int32_t yy = 0; for (; yy + 2 <= vshrink; yy += 2) { auto pix0 = PromoteTo(du32, LoadU(du8x32, p)); - p += l1; + p += ne; auto pix1 = PromoteTo(du32, LoadU(du8x32, p)); - p += l1; + p += ne; pix0 = Add(pix0, pix1); sum0 = Add(sum0, pix0); } for (; yy < vshrink; ++yy) { auto pix0 = PromoteTo(du32, LoadU(du8x32, p)); - p += l1; + p += ne; sum0 = Add(sum0, pix0); } @@ -196,11 +194,10 @@ HWY_EXPORT(vips_shrinkv_uchar_hwy); void vips_shrinkv_uchar_hwy(VipsPel *pout, VipsPel *pin, - int ne, int vshrink, int lskip) + int ne, int vshrink) { /* clang-format off */ - HWY_DYNAMIC_DISPATCH(vips_shrinkv_uchar_hwy)(pout, pin, - ne, vshrink, lskip); + HWY_DYNAMIC_DISPATCH(vips_shrinkv_uchar_hwy)(pout, pin, ne, vshrink); /* clang-format on */ } #endif /*HWY_ONCE*/