Fix: Byte interpolation with clamped boundary returns zero

The byte BLI image interpolation function with clamped boundary returns
zero for out of bound pixels. This is the same as #119164, but for byte
interpolation.

Pull Request: https://projects.blender.org/blender/blender/pulls/119173
This commit is contained in:
Omar Emara 2024-03-08 07:50:01 +01:00 committed by Omar Emara
parent f3e0e39df5
commit a444a5eeba
1 changed files with 3 additions and 11 deletions

View File

@ -406,17 +406,9 @@ BLI_INLINE uchar4 bilinear_byte_impl(const uchar *buffer, int width, int height,
y1234 = _mm_andnot_si128(invalid_1234, y1234);
}
else {
/* Clamp samples to image edges, unless all four of them are outside
* in which case return black. */
/* Clamp samples to image edges. */
__m128i xy12_clamped = max_i_simd(xy12, _mm_setzero_si128());
xy12_clamped = min_i_simd(xy12_clamped, size_minus_1);
__m128i valid_xy12 = _mm_cmpeq_epi32(xy12, xy12_clamped);
__m128i valid_pairs = _mm_and_si128(valid_xy12,
_mm_shuffle_epi32(valid_xy12, _MM_SHUFFLE(0, 3, 2, 1)));
if (_mm_movemask_ps(_mm_castsi128_ps(valid_pairs)) == 0) {
return uchar4(0);
}
x1234 = _mm_shuffle_epi32(xy12_clamped, _MM_SHUFFLE(2, 2, 0, 0));
y1234 = _mm_shuffle_epi32(xy12_clamped, _MM_SHUFFLE(3, 1, 3, 1));
}
@ -480,8 +472,8 @@ BLI_INLINE uchar4 bilinear_byte_impl(const uchar *buffer, int width, int height,
int y1 = int(vf);
int y2 = y1 + 1;
/* Completely outside of the image? */
if (x2 < 0 || x1 >= width || y2 < 0 || y1 >= height) {
/* Completely outside of the image in bordered mode? */
if (border && (x2 < 0 || x1 >= width || y2 < 0 || y1 >= height)) {
return uchar4(0);
}