@@ -243,9 +243,9 @@ static int interp_##nbits##_##name##_p##depth(AVFilterContext *ctx, void *arg, i
srcg[x] * scale_g, \
srcb[x] * scale_b}; \
struct rgbvec vec = interp_##name(lut3d, &scaled_rgb); \
- dstr[x] = av_clip_uintp2(vec.r * (float)((1<<depth) - 1), depth); \
- dstg[x] = av_clip_uintp2(vec.g * (float)((1<<depth) - 1), depth); \
- dstb[x] = av_clip_uintp2(vec.b * (float)((1<<depth) - 1), depth); \
+ dstr[x] = av_clip_uintp2(vec.r * (float)((1<<depth) - 1) + 0.5f, depth); \
+ dstg[x] = av_clip_uintp2(vec.g * (float)((1<<depth) - 1) + 0.5f, depth); \
+ dstb[x] = av_clip_uintp2(vec.b * (float)((1<<depth) - 1) + 0.5f, depth); \
if (!direct && in->linesize[3]) \
dsta[x] = srca[x]; \
} \
@@ -315,9 +315,9 @@ static int interp_##nbits##_##name(AVFilterContext *ctx, void *arg, int jobnr, i
src[x + g] * scale_g, \
src[x + b] * scale_b}; \
struct rgbvec vec = interp_##name(lut3d, &scaled_rgb); \
- dst[x + r] = av_clip_uint##nbits(vec.r * (float)((1<<nbits) - 1)); \
- dst[x + g] = av_clip_uint##nbits(vec.g * (float)((1<<nbits) - 1)); \
- dst[x + b] = av_clip_uint##nbits(vec.b * (float)((1<<nbits) - 1)); \
+ dst[x + r] = av_clip_uint##nbits(vec.r * (float)((1<<nbits) - 1) + 0.5f); \
+ dst[x + g] = av_clip_uint##nbits(vec.g * (float)((1<<nbits) - 1) + 0.5f); \
+ dst[x + b] = av_clip_uint##nbits(vec.b * (float)((1<<nbits) - 1) + 0.5f); \
if (!direct && step == 4) \
dst[x + a] = src[x + a]; \
} \
@@ -1423,9 +1423,9 @@ static int interp_1d_##nbits##_##name##_p##depth(AVFilterContext *ctx, \
r = interp_1d_##name(lut1d, 0, r); \
g = interp_1d_##name(lut1d, 1, g); \
b = interp_1d_##name(lut1d, 2, b); \
- dstr[x] = av_clip_uintp2(r * factor, depth); \
- dstg[x] = av_clip_uintp2(g * factor, depth); \
- dstb[x] = av_clip_uintp2(b * factor, depth); \
+ dstr[x] = av_clip_uintp2(r * factor + 0.5f, depth); \
+ dstg[x] = av_clip_uintp2(g * factor + 0.5f, depth); \
+ dstb[x] = av_clip_uintp2(b * factor + 0.5f, depth); \
if (!direct && in->linesize[3]) \
dsta[x] = srca[x]; \
} \
@@ -1511,9 +1511,9 @@ static int interp_1d_##nbits##_##name(AVFilterContext *ctx, void *arg, \
rr = interp_1d_##name(lut1d, 0, rr); \
gg = interp_1d_##name(lut1d, 1, gg); \
bb = interp_1d_##name(lut1d, 2, bb); \
- dst[x + r] = av_clip_uint##nbits(rr * factor); \
- dst[x + g] = av_clip_uint##nbits(gg * factor); \
- dst[x + b] = av_clip_uint##nbits(bb * factor); \
+ dst[x + r] = av_clip_uint##nbits(rr * factor + 0.5f); \
+ dst[x + g] = av_clip_uint##nbits(gg * factor + 0.5f); \
+ dst[x + b] = av_clip_uint##nbits(bb * factor + 0.5f); \
if (!direct && step == 4) \
dst[x + a] = src[x + a]; \
} \