lib/imlib: Add rgb565 to rgb888 simd conversion.

This commit is contained in:
Kwabena W. Agyeman 2025-08-05 10:42:29 -07:00
parent 1b2c38fa6d
commit 0e9e936553

View File

@ -1811,6 +1811,24 @@ static inline v128_t vrgb_pixels_to_grayscale(vrgb_pixels_t pixels) {
return vlsr_u32(pixels.r, 7);
}
// In the case of vectors larger than 32-bits the pattern is repeated for every 32-bits.
//
// 2x uint16_t RGB565 (MSB [RGB1, RGB0] LSB) pixels for every 32-bits.
//
// Returns pixels.r = MSB [0, R1, 0, R0] LSB pixels where each pixel is 8-bits.
// Returns pixels.g = MSB [0, G1, 0, G0] LSB pixels where each pixel is 8-bits.
// Returns pixels.b = MSB [0, B1, 0, B0] LSB pixels where each pixel is 8-bits.
static inline vrgb_pixels_t vrgb_rgb565_to_pixels888(v128_t rgb565) {
vrgb_pixels_t pixels;
pixels.r = vand_u32(vlsr_u32(rgb565, 8), vdup_u16(0xf8));
pixels.r = vorr_u32(pixels.r, vlsr_u32(pixels.r, 5));
pixels.g = vand_u32(vlsr_u32(rgb565, 3), vdup_u16(0xfc));
pixels.g = vorr_u32(pixels.g, vlsr_u32(pixels.g, 6));
pixels.b = vand_u32(vlsl_u32(rgb565, 3), vdup_u16(0xf8));
pixels.b = vorr_u32(pixels.b, vlsr_u32(pixels.b, 5));
return pixels;
}
// In the case of vectors larger than 32-bits the pattern is repeated for every 32-bits.
//
// pixels.r = MSB [0, R1, 0, R0] LSB pixels where each pixel is 8-bits.