Skip to content

Commit

Permalink
Remove redundant lskip variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Nov 21, 2024
1 parent 8f99346 commit 3f6ce63
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions libvips/resample/presample.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions libvips/resample/reducev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 9 additions & 11 deletions libvips/resample/reducev_hwy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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*/
Expand Down
4 changes: 1 addition & 3 deletions libvips/resample/shrinkv.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,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
Expand All @@ -373,7 +371,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");
Expand Down
21 changes: 9 additions & 12 deletions libvips/resample/shrinkv_hwy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ constexpr int32_t max_bits = 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.
Expand All @@ -105,9 +103,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);

Expand All @@ -116,7 +114,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)));
Expand Down Expand Up @@ -159,16 +157,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);
}
Expand All @@ -195,11 +193,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*/
Expand Down

0 comments on commit 3f6ce63

Please sign in to comment.