aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2024-05-09 00:17:53 +0200
committerMarton Balint <cus@passwd.hu>2024-05-14 21:07:37 +0200
commitb0093ab8a3d34bf2fefd6665464cc343a9ef0d53 (patch)
tree4782c31d3ce46fb8b9f7124dc20f9835c8deb6ee
parent64330e365b97d9b8304a9d3d306581b6c14a773b (diff)
downloadffmpeg-b0093ab8a3d34bf2fefd6665464cc343a9ef0d53.tar.gz
avfilter/vf_geq: fix interpolation with 1 pixel width/height
Fixes ticket #9740. Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r--libavfilter/vf_geq.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c
index dbe50e5250..0efbce4d4f 100644
--- a/libavfilter/vf_geq.c
+++ b/libavfilter/vf_geq.c
@@ -112,8 +112,12 @@ static inline double getpix(void *priv, double x, double y, int plane)
return 0;
if (geq->interpolation == INTERP_BILINEAR) {
- xi = x = av_clipd(x, 0, w - 2);
- yi = y = av_clipd(y, 0, h - 2);
+ int xn, yn;
+
+ xi = x = av_clipd(x, 0, w - 1);
+ yi = y = av_clipd(y, 0, h - 1);
+ xn = FFMIN(xi + 1, w - 1);
+ yn = FFMIN(yi + 1, h - 1);
x -= xi;
y -= yi;
@@ -122,17 +126,17 @@ static inline double getpix(void *priv, double x, double y, int plane)
const uint16_t *src16 = (const uint16_t*)src;
linesize /= 2;
- return (1-y)*((1-x)*src16[xi + yi * linesize] + x*src16[xi + 1 + yi * linesize])
- + y *((1-x)*src16[xi + (yi+1) * linesize] + x*src16[xi + 1 + (yi+1) * linesize]);
+ return (1-y)*((1-x)*src16[xi + yi * linesize] + x*src16[xn + yi * linesize])
+ + y *((1-x)*src16[xi + yn * linesize] + x*src16[xn + yn * linesize]);
} else if (geq->bps == 32) {
const float *src32 = (const float*)src;
linesize /= 4;
- return (1-y)*((1-x)*src32[xi + yi * linesize] + x*src32[xi + 1 + yi * linesize])
- + y *((1-x)*src32[xi + (yi+1) * linesize] + x*src32[xi + 1 + (yi+1) * linesize]);
+ return (1-y)*((1-x)*src32[xi + yi * linesize] + x*src32[xn + yi * linesize])
+ + y *((1-x)*src32[xi + yn * linesize] + x*src32[xn + yn * linesize]);
} else if (geq->bps == 8) {
- return (1-y)*((1-x)*src[xi + yi * linesize] + x*src[xi + 1 + yi * linesize])
- + y *((1-x)*src[xi + (yi+1) * linesize] + x*src[xi + 1 + (yi+1) * linesize]);
+ return (1-y)*((1-x)*src[xi + yi * linesize] + x*src[xn + yi * linesize])
+ + y *((1-x)*src[xi + yn * linesize] + x*src[xn + yn * linesize]);
}
} else {
xi = av_clipd(x, 0, w - 1);