mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #932 from kwagyeman/kwabena/fix_rgb565_inversion_2
Kwabena/fix rgb565 inversion
This commit is contained in:
commit
f79167de4b
@ -1,4 +1,4 @@
|
||||
def unittest(data_path, temp_path):
|
||||
import image
|
||||
lab = image.rgb_to_lab((120, 200, 120))
|
||||
return (lab[0] == 74 and lab[1] == -38 and lab[2] == 30)
|
||||
return (lab[0] == 75 and lab[1] == -40 and lab[2] == 32)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
def unittest(data_path, temp_path):
|
||||
import image
|
||||
rgb = image.lab_to_rgb((74, -38, 30))
|
||||
return (rgb[0] == 123 and rgb[1] == 198 and rgb[2] == 123)
|
||||
return (rgb[0] == 123 and rgb[1] == 199 and rgb[2] == 123)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
def unittest(data_path, temp_path):
|
||||
import image
|
||||
gs = image.rgb_to_grayscale((120, 200, 120))
|
||||
return (gs == 166)
|
||||
return (gs == 169)
|
||||
|
||||
@ -7,6 +7,6 @@ def unittest(data_path, temp_path):
|
||||
img = image.Image("unittest/data/blobs.ppm", copy_to_fb=True)
|
||||
|
||||
blobs = img.find_blobs(thresholds, pixels_threshold=2000, area_threshold=200)
|
||||
return [int(x) for x in blobs[0][0:-5]] == [122, 41, 97, 82, 6228, 168, 82] and\
|
||||
[int(x) for x in blobs[1][0:-5]] == [44, 40, 78, 90, 5113, 80, 84] and\
|
||||
[int(x) for x in blobs[2][0:-5]] == [210, 40, 72, 83, 3890, 249, 76]
|
||||
return [int(x) for x in blobs[0][0:-5]] == [122, 41, 97, 82, 6266, 168, 82] and\
|
||||
[int(x) for x in blobs[1][0:-5]] == [44, 42, 78, 88, 5162, 81, 85] and\
|
||||
[int(x) for x in blobs[2][0:-5]] == [210, 40, 72, 83, 3930, 249, 77]
|
||||
|
||||
@ -2,4 +2,4 @@ def unittest(data_path, temp_path):
|
||||
import image
|
||||
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
|
||||
circles = img.find_circles(threshold = 5000, x_margin = 30, y_margin = 30, r_margin = 30)
|
||||
return len(circles) == 1 and circles[0][0:] == (118, 56, 22, 5858)
|
||||
return len(circles) == 1 and circles[0][0:] == (118, 56, 22, 5856)
|
||||
|
||||
@ -3,7 +3,7 @@ def unittest(data_path, temp_path):
|
||||
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
|
||||
lines = img.find_lines(threshold = 10000, theta_margin = 25, rho_margin = 25)
|
||||
return len(lines) == 4 and\
|
||||
lines[0][0:] == (22, 0, 22, 119, 119, 17272, 0, 22) and\
|
||||
lines[1][0:] == (0, 39, 159, 39, 159, 17272, 90, 39) and\
|
||||
lines[2][0:] == (57, 0, 57, 119, 119, 17272, 0, 57) and\
|
||||
lines[3][0:] == (0, 75, 159, 75, 159, 21336, 90, 75)
|
||||
lines[0][0:] == (22, 0, 22, 119, 119, 17340, 0, 22) and\
|
||||
lines[1][0:] == (0, 39, 159, 39, 159, 17340, 90, 39) and\
|
||||
lines[2][0:] == (57, 0, 57, 119, 119, 17340, 0, 57) and\
|
||||
lines[3][0:] == (0, 75, 159, 75, 159, 21420, 90, 75)
|
||||
|
||||
@ -7,6 +7,6 @@ def unittest(data_path, temp_path):
|
||||
lines[1][0:] == (24, 74, 56, 74, 32, 19, 90, 74) and\
|
||||
lines[2][0:] == (54, 38, 26, 38, 28, 14, 90, 38) and\
|
||||
lines[3][0:] == (104, 70, 114, 76, 12, 2, 121, 6) and\
|
||||
lines[4][0:] == (139, 51, 133, 41, 12, 2, 149, -93) and\
|
||||
lines[5][0:] == (109, 37, 100, 46, 13, 12, 45, 103) and\
|
||||
lines[6][0:] == (127, 75, 138, 64, 16, 1, 45, 143)
|
||||
lines[4][0:] == (139, 51, 133, 41, 12, 3, 149, -93) and\
|
||||
lines[5][0:] == (109, 37, 100, 46, 13, 14, 45, 103) and\
|
||||
lines[6][0:] == (129, 73, 137, 64, 12, 8, 42, 145)
|
||||
|
||||
@ -2,4 +2,4 @@ def unittest(data_path, temp_path):
|
||||
import image
|
||||
img = image.Image("unittest/data/shapes.ppm", copy_to_fb=True)
|
||||
rects = img.find_rects(threshold = 50000)
|
||||
return len(rects) == 1 and rects[0][0:] == (23, 39, 35, 36, 145992)
|
||||
return len(rects) == 1 and rects[0][0:] == (23, 39, 35, 36, 146566)
|
||||
|
||||
@ -260,7 +260,6 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/img/,\
|
||||
xyz_tab.o \
|
||||
yuv_tab.o \
|
||||
rainbow_tab.o \
|
||||
rgb2rgb_tab.o \
|
||||
invariant_tab.o \
|
||||
mathop.o \
|
||||
pool.o \
|
||||
@ -588,7 +587,6 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/img/,\
|
||||
xyz_tab.o \
|
||||
yuv_tab.o \
|
||||
rainbow_tab.o \
|
||||
rgb2rgb_tab.o \
|
||||
invariant_tab.o \
|
||||
jpeg.o \
|
||||
fmath.o \
|
||||
|
||||
@ -59,7 +59,6 @@ SRCS += $(addprefix img/, \
|
||||
xyz_tab.c \
|
||||
yuv_tab.c \
|
||||
rainbow_tab.c \
|
||||
rgb2rgb_tab.c \
|
||||
invariant_tab.c \
|
||||
mathop.c \
|
||||
pool.c \
|
||||
|
||||
@ -152,7 +152,6 @@ void bmp_read_pixels(FIL *fp, image_t *img, int n_lines, bmp_read_settings_t *rs
|
||||
for (int j = 0, jj = rs->bmp_row_bytes / 2; j < jj; j++) {
|
||||
uint16_t pixel;
|
||||
read_word(fp, &pixel);
|
||||
pixel = IM_SWAP16(pixel);
|
||||
if (j < img->w) {
|
||||
if (rs->bmp_h < 0) { // vertical flip (BMP file perspective)
|
||||
if (rs->bmp_w < 0) { // horizontal flip (BMP file perspective)
|
||||
@ -177,7 +176,7 @@ void bmp_read_pixels(FIL *fp, image_t *img, int n_lines, bmp_read_settings_t *rs
|
||||
read_byte(fp, &b);
|
||||
read_byte(fp, &g);
|
||||
read_byte(fp, &r);
|
||||
uint16_t pixel = IM_RGB565(IM_R825(r), IM_G826(g), IM_B825(b));
|
||||
uint16_t pixel = COLOR_R8_G8_B8_TO_RGB565(r, g, b);
|
||||
if (j < img->w) {
|
||||
if (rs->bmp_h < 0) { // vertical flip
|
||||
if (rs->bmp_w < 0) { // horizontal flip
|
||||
@ -290,7 +289,7 @@ void bmp_write_subimg(image_t *img, const char *path, rectangle_t *r)
|
||||
write_long(&fp, 0x1F);
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
write_word(&fp, IM_SWAP16(IM_GET_RGB565_PIXEL(img, (rect.x + j), (rect.y + i))));
|
||||
write_word(&fp, IM_GET_RGB565_PIXEL(img, (rect.x + j), (rect.y + i)));
|
||||
}
|
||||
for (int j = 0; j < waste; j++) {
|
||||
write_word(&fp, 0);
|
||||
|
||||
@ -473,23 +473,23 @@ void imlib_draw_row_setup(imlib_draw_row_data_t *data)
|
||||
if (!data->alpha_palette) {
|
||||
if (!data->color_palette) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
clut[i] = (0xff << 24) | Y_TO_RGB888_FAST(i);
|
||||
clut[i] = (0xff << 24) | COLOR_Y_TO_RGB888(i);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int pixel = color_palette[i];
|
||||
clut[i] = (0xff << 24) | (RGB565_TO_R8_FAST(pixel) << 16) | (RGB565_TO_G8_FAST(pixel) << 8) | RGB565_TO_B8_FAST(pixel);
|
||||
clut[i] = (0xff << 24) | (COLOR_RGB565_TO_R8(pixel) << 16) | (COLOR_RGB565_TO_G8(pixel) << 8) | COLOR_RGB565_TO_B8(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!data->color_palette) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
clut[i] = (alpha_palette[i] << 24) | Y_TO_RGB888_FAST(i);
|
||||
clut[i] = (alpha_palette[i] << 24) | COLOR_Y_TO_RGB888(i);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int pixel = color_palette[i];
|
||||
clut[i] = (alpha_palette[i] << 24) | (RGB565_TO_R8_FAST(pixel) << 16) | (RGB565_TO_G8_FAST(pixel) << 8) | RGB565_TO_B8_FAST(pixel);
|
||||
clut[i] = (alpha_palette[i] << 24) | (COLOR_RGB565_TO_R8(pixel) << 16) | (COLOR_RGB565_TO_G8(pixel) << 8) | COLOR_RGB565_TO_B8(pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -575,16 +575,13 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
({ \
|
||||
__typeof__ (src_pixel) _src_pixel = (src_pixel); \
|
||||
__typeof__ (dst_pixel) _dst_pixel = (dst_pixel); \
|
||||
_src_pixel = __REV16(_src_pixel); /* RGB565 byte reversal fix */ \
|
||||
_dst_pixel = __REV16(_dst_pixel); /* RGB565 byte reversal fix */ \
|
||||
const long mask_r = 0x7c007c00, mask_g = 0x07e007e0, mask_b = 0x001f001f; \
|
||||
uint32_t rgb = (_src_pixel << 16) | _dst_pixel; \
|
||||
long rb = ((rgb >> 1) & mask_r) | (rgb & mask_b); \
|
||||
long g = rgb & mask_g; \
|
||||
int rb_out = __SMUAD(smuad_alpha, rb) >> 5; \
|
||||
int g_out = __SMUAD(smuad_alpha, g) >> 5; \
|
||||
int pixel = ((rb_out << 1) & 0xf800) | (g_out & 0x07e0) | (rb_out & 0x001f); \
|
||||
pixel = __REV16(pixel); /* RGB565 byte reversal fix */ \
|
||||
((rb_out << 1) & 0xf800) | (g_out & 0x07e0) | (rb_out & 0x001f); \
|
||||
})
|
||||
|
||||
switch (data->dst_img->bpp) {
|
||||
@ -608,8 +605,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint32_t alpha_pal0 = smuad_alpha_palette[0], alpha_pal255 = smuad_alpha_palette[255];
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0);
|
||||
pal255 = RGB565_TO_Y_FAST(pal255);
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0);
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255);
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = IMAGE_GET_BINARY_PIXEL_FAST(src32, x);
|
||||
long smuad_alpha = pixel ? alpha_pal255 : alpha_pal0;
|
||||
@ -627,8 +624,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0) > 127;
|
||||
pal255 = RGB565_TO_Y_FAST(pal255) > 127;
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0) > 127;
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255) > 127;
|
||||
switch ((pal0 << 1) | (pal255 << 0)) {
|
||||
case 0: {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
@ -669,8 +666,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0);
|
||||
pal255 = RGB565_TO_Y_FAST(pal255);
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0);
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255);
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = IMAGE_GET_BINARY_PIXEL_FAST(src32, x) ? pal255 : pal0;
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
@ -687,8 +684,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
// } else {
|
||||
// const uint16_t *color_palette = data->color_palette;
|
||||
// uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
// pal0 = RGB565_TO_Y_FAST(pal0) > 127;
|
||||
// pal255 = RGB565_TO_Y_FAST(pal255) > 127;
|
||||
// pal0 = COLOR_RGB565_TO_Y(pal0) > 127;
|
||||
// pal255 = COLOR_RGB565_TO_Y(pal255) > 127;
|
||||
// switch ((pal0 << 1) | (pal255 << 0)) {
|
||||
// case 0: {
|
||||
// for (int x = x_start; x < x_end; x++) {
|
||||
@ -739,7 +736,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
int pixel = *src8++;
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
pixel = color_palette[pixel];
|
||||
pixel = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
@ -755,7 +752,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = color_palette[*src8++];
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
}
|
||||
@ -771,7 +768,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = color_palette[*src8++];
|
||||
pixel = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
@ -788,7 +785,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
@ -798,10 +795,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_Y_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -810,15 +807,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_Y_FAST(pixel)];
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = color_palette[COLOR_RGB565_TO_Y(pixel)];
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
}
|
||||
@ -827,7 +824,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -835,8 +832,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_Y_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = color_palette[COLOR_RGB565_TO_Y(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -848,7 +845,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_R8_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_R8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
@ -858,10 +855,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_R8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_R8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -870,15 +867,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_R8_FAST(pixel) > 127;
|
||||
pixel = COLOR_RGB565_TO_R8(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_R8_FAST(pixel)];
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = color_palette[COLOR_RGB565_TO_R8(pixel)];
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
}
|
||||
@ -887,7 +884,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_R8_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_R8(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -895,8 +892,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_R8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = color_palette[COLOR_RGB565_TO_R8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -908,7 +905,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_G8_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_G8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
@ -918,10 +915,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_G8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_G8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -930,15 +927,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_G8_FAST(pixel) > 127;
|
||||
pixel = COLOR_RGB565_TO_G8(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_G8_FAST(pixel)];
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = color_palette[COLOR_RGB565_TO_G8(pixel)];
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
}
|
||||
@ -947,7 +944,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_G8_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_G8(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -955,8 +952,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_G8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = color_palette[COLOR_RGB565_TO_G8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -968,7 +965,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_B8_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_B8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
long smuad_pixel = (pixel << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
@ -978,10 +975,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_B8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_B8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -990,15 +987,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_B8_FAST(pixel) > 127;
|
||||
pixel = COLOR_RGB565_TO_B8(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_B8_FAST(pixel)];
|
||||
pixel = RGB565_TO_Y_FAST(pixel) > 127;
|
||||
pixel = color_palette[COLOR_RGB565_TO_B8(pixel)];
|
||||
pixel = COLOR_RGB565_TO_Y(pixel) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
}
|
||||
@ -1007,7 +1004,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_B8_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
long smuad_pixel = (COLOR_RGB565_TO_B8(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -1015,8 +1012,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_B8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = color_palette[COLOR_RGB565_TO_B8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | (IMAGE_GET_BINARY_PIXEL_FAST(dst32, x) ? 0xff : 0x00);
|
||||
pixel = (__SMUAD(smuad_alpha, smuad_pixel) >> 8) > 127;
|
||||
IMAGE_PUT_BINARY_PIXEL_FAST(dst32, x, pixel);
|
||||
}
|
||||
@ -1050,8 +1047,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint32_t alpha_pal0 = smuad_alpha_palette[0], alpha_pal255 = smuad_alpha_palette[255];
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0);
|
||||
pal255 = RGB565_TO_Y_FAST(pal255);
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0);
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255);
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = IMAGE_GET_BINARY_PIXEL_FAST(src32, x);
|
||||
long smuad_alpha = pixel ? alpha_pal255 : alpha_pal0;
|
||||
@ -1067,8 +1064,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0);
|
||||
pal255 = RGB565_TO_Y_FAST(pal255);
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0);
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255);
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
*dst8++ = IMAGE_GET_BINARY_PIXEL_FAST(src32, x) ? pal255 : pal0;
|
||||
}
|
||||
@ -1083,8 +1080,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
uint16_t pal0 = color_palette[0], pal255 = color_palette[255];
|
||||
pal0 = RGB565_TO_Y_FAST(pal0);
|
||||
pal255 = RGB565_TO_Y_FAST(pal255);
|
||||
pal0 = COLOR_RGB565_TO_Y(pal0);
|
||||
pal255 = COLOR_RGB565_TO_Y(pal255);
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
long smuad_pixel = ((IMAGE_GET_BINARY_PIXEL_FAST(src32, x) ? pal255 : pal0) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
@ -1110,7 +1107,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
int pixel = *src8++;
|
||||
long smuad_alpha = smuad_alpha_palette[pixel];
|
||||
pixel = color_palette[pixel];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1121,7 +1118,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = color_palette[*src8++];
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1135,7 +1132,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = color_palette[*src8++];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1150,7 +1147,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_Y_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
long smuad_pixel = (pixel_y << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
@ -1159,10 +1156,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_Y_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_Y(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1170,14 +1167,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_Y_FAST(pixel)];
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = color_palette[COLOR_RGB565_TO_Y(pixel)];
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1185,15 +1182,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_Y_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
pixel = color_palette[COLOR_RGB565_TO_Y(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1204,7 +1201,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_R8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_R8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
long smuad_pixel = (pixel_y << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
@ -1213,10 +1210,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_R8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_R8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1224,14 +1221,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst8++ = RGB565_TO_R8_FAST(pixel);
|
||||
*dst8++ = COLOR_RGB565_TO_R8(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_R8_FAST(pixel)];
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = color_palette[COLOR_RGB565_TO_R8(pixel)];
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1239,15 +1236,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_R8_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_R8(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_R8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
pixel = color_palette[COLOR_RGB565_TO_R8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1258,7 +1255,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_G8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_G8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
long smuad_pixel = (pixel_y << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
@ -1267,10 +1264,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_G8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_G8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1278,14 +1275,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst8++ = RGB565_TO_G8_FAST(pixel);
|
||||
*dst8++ = COLOR_RGB565_TO_G8(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_G8_FAST(pixel)];
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = color_palette[COLOR_RGB565_TO_G8(pixel)];
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1293,15 +1290,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_G8_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_G8(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_G8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
pixel = color_palette[COLOR_RGB565_TO_G8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1312,7 +1309,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_B8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_B8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
long smuad_pixel = (pixel_y << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
@ -1321,10 +1318,10 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
int pixel_y = RGB565_TO_B8_FAST(pixel);
|
||||
int pixel_y = COLOR_RGB565_TO_B8(pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[pixel_y];
|
||||
pixel = color_palette[pixel_y];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1332,14 +1329,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst8++ = RGB565_TO_B8_FAST(pixel);
|
||||
*dst8++ = COLOR_RGB565_TO_B8(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_B8_FAST(pixel)];
|
||||
*dst8++ = RGB565_TO_Y_FAST(pixel);
|
||||
pixel = color_palette[COLOR_RGB565_TO_B8(pixel)];
|
||||
*dst8++ = COLOR_RGB565_TO_Y(pixel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1347,15 +1344,15 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
long smuad_pixel = (RGB565_TO_B8_FAST(pixel) << 16) | *dst8;
|
||||
long smuad_pixel = (COLOR_RGB565_TO_B8(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = color_palette[RGB565_TO_B8_FAST(pixel)];
|
||||
long smuad_pixel = (RGB565_TO_Y_FAST(pixel) << 16) | *dst8;
|
||||
pixel = color_palette[COLOR_RGB565_TO_B8(pixel)];
|
||||
long smuad_pixel = (COLOR_RGB565_TO_Y(pixel) << 16) | *dst8;
|
||||
*dst8++ = __SMUAD(smuad_alpha, smuad_pixel) >> 8;
|
||||
}
|
||||
}
|
||||
@ -1441,7 +1438,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src8++;
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel];
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1459,7 +1456,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src8++;
|
||||
*dst16++ = Y_TO_RGB565_FAST(pixel);
|
||||
*dst16++ = COLOR_Y_TO_RGB565(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
@ -1472,7 +1469,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src8++;
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1496,7 +1493,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
long smuad_alpha = smuad_alpha_palette[RGB565_TO_Y_FAST(src_pixel)];
|
||||
long smuad_alpha = smuad_alpha_palette[COLOR_RGB565_TO_Y(src_pixel)];
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1504,7 +1501,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_Y_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_Y(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = color_palette[src_pixel_y];
|
||||
int dst_pixel = *dst16;
|
||||
@ -1523,7 +1520,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst16++ = color_palette[RGB565_TO_Y_FAST(pixel)];
|
||||
*dst16++ = color_palette[COLOR_RGB565_TO_Y(pixel)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1543,7 +1540,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = color_palette[RGB565_TO_Y_FAST(src_pixel)];
|
||||
src_pixel = color_palette[COLOR_RGB565_TO_Y(src_pixel)];
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1555,9 +1552,9 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_R8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_R8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel_y);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel_y);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1565,7 +1562,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_R8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_R8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = color_palette[src_pixel_y];
|
||||
int dst_pixel = *dst16;
|
||||
@ -1576,14 +1573,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_R8_FAST(pixel);
|
||||
*dst16++ = Y_TO_RGB565_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_R8(pixel);
|
||||
*dst16++ = COLOR_Y_TO_RGB565(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst16++ = color_palette[RGB565_TO_R8_FAST(pixel)];
|
||||
*dst16++ = color_palette[COLOR_RGB565_TO_R8(pixel)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1591,8 +1588,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = RGB565_TO_R8_FAST(src_pixel);
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel);
|
||||
src_pixel = COLOR_RGB565_TO_R8(src_pixel);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1600,7 +1597,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = color_palette[RGB565_TO_R8_FAST(src_pixel)];
|
||||
src_pixel = color_palette[COLOR_RGB565_TO_R8(src_pixel)];
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1612,9 +1609,9 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_G8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_G8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel_y);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel_y);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1622,7 +1619,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_G8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_G8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = color_palette[src_pixel_y];
|
||||
int dst_pixel = *dst16;
|
||||
@ -1633,14 +1630,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_G8_FAST(pixel);
|
||||
*dst16++ = Y_TO_RGB565_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_G8(pixel);
|
||||
*dst16++ = COLOR_Y_TO_RGB565(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst16++ = color_palette[RGB565_TO_G8_FAST(pixel)];
|
||||
*dst16++ = color_palette[COLOR_RGB565_TO_G8(pixel)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1648,8 +1645,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = RGB565_TO_G8_FAST(src_pixel);
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel);
|
||||
src_pixel = COLOR_RGB565_TO_G8(src_pixel);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1657,7 +1654,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = color_palette[RGB565_TO_G8_FAST(src_pixel)];
|
||||
src_pixel = color_palette[COLOR_RGB565_TO_G8(src_pixel)];
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1669,9 +1666,9 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_B8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_B8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel_y);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel_y);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1679,7 +1676,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
int src_pixel_y = RGB565_TO_B8_FAST(src_pixel);
|
||||
int src_pixel_y = COLOR_RGB565_TO_B8(src_pixel);
|
||||
long smuad_alpha = smuad_alpha_palette[src_pixel_y];
|
||||
src_pixel = color_palette[src_pixel_y];
|
||||
int dst_pixel = *dst16;
|
||||
@ -1690,14 +1687,14 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
pixel = RGB565_TO_B8_FAST(pixel);
|
||||
*dst16++ = Y_TO_RGB565_FAST(pixel);
|
||||
pixel = COLOR_RGB565_TO_B8(pixel);
|
||||
*dst16++ = COLOR_Y_TO_RGB565(pixel);
|
||||
}
|
||||
} else {
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int pixel = *src16++;
|
||||
*dst16++ = color_palette[RGB565_TO_B8_FAST(pixel)];
|
||||
*dst16++ = color_palette[COLOR_RGB565_TO_B8(pixel)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1705,8 +1702,8 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
if (!data->color_palette) {
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = RGB565_TO_B8_FAST(src_pixel);
|
||||
src_pixel = Y_TO_RGB565_FAST(src_pixel);
|
||||
src_pixel = COLOR_RGB565_TO_B8(src_pixel);
|
||||
src_pixel = COLOR_Y_TO_RGB565(src_pixel);
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -1714,7 +1711,7 @@ void imlib_draw_row(int x_start, int x_end, int y_row, imlib_draw_row_data_t *da
|
||||
const uint16_t *color_palette = data->color_palette;
|
||||
for (int x = x_start; x < x_end; x++) {
|
||||
int src_pixel = *src16++;
|
||||
src_pixel = color_palette[RGB565_TO_B8_FAST(src_pixel)];
|
||||
src_pixel = color_palette[COLOR_RGB565_TO_B8(src_pixel)];
|
||||
int dst_pixel = *dst16;
|
||||
*dst16++ = BLEND_RGB566(src_pixel, dst_pixel, smuad_alpha);
|
||||
}
|
||||
@ -2084,9 +2081,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
for (; n > 1; n -= 2) {
|
||||
uint32_t pixels = *src_row_ptr32++;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixels = __REV16(pixels);
|
||||
|
||||
long r = (pixels >> 11) & 0x1F001F;
|
||||
r_acc = __USADA8(r, 0, r_acc);
|
||||
|
||||
@ -2480,9 +2474,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int t_r_pixel = IMAGE_GET_RGB565_PIXEL_FAST(t_src_row_ptr, src_x_index_end);
|
||||
int t_pixels = (t_l_pixel << 16) | t_r_pixel;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
t_pixels = __REV16(t_pixels);
|
||||
|
||||
long t_r = (t_pixels >> 11) & 0x1F001F;
|
||||
r_acc = __SMLAD(t_r, t_smlad_x_weight, r_acc);
|
||||
|
||||
@ -2496,9 +2487,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int b_r_pixel = IMAGE_GET_RGB565_PIXEL_FAST(b_src_row_ptr, src_x_index_end);
|
||||
int b_pixels = (b_l_pixel << 16) | b_r_pixel;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
b_pixels = __REV16(b_pixels);
|
||||
|
||||
long b_r = (b_pixels >> 11) & 0x1F001F;
|
||||
r_acc = __SMLAD(b_r, b_smlad_x_weight, r_acc);
|
||||
|
||||
@ -2522,9 +2510,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int b_y_pixel = *b_src_row_ptr_tmp++;
|
||||
int pixels = (t_y_pixel << 16) | b_y_pixel;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixels = __REV16(pixels);
|
||||
|
||||
long r = (pixels >> 11) & 0x1F001F;
|
||||
r_acc = __SMLAD(r, smlad_y_weight, r_acc);
|
||||
|
||||
@ -2544,9 +2529,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int r_x_pixel = IMAGE_GET_RGB565_PIXEL_FAST(src_row_ptr, src_x_index_end);
|
||||
int pixels = (l_x_pixel << 16) | r_x_pixel;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixels = __REV16(pixels);
|
||||
|
||||
long r = (pixels >> 11) & 0x1F001F;
|
||||
r_acc = __SMLAD(r, smlad_x_weight, r_acc);
|
||||
|
||||
@ -2574,9 +2556,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
for (; n > 1; n -= 2) {
|
||||
uint32_t pixels = *src_row_ptr32++;
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixels = __REV16(pixels);
|
||||
|
||||
long r = (pixels >> 11) & 0x1F001F;
|
||||
r_acc = __USADA8(r, 0, r_acc);
|
||||
|
||||
@ -3125,12 +3104,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
|
||||
for (int z = 0; z < 2; z++) { // dual bicubic x step (-1 to +2)
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixel_row_0[z] = __REV16(pixel_row_0[z]);
|
||||
pixel_row_1[z] = __REV16(pixel_row_1[z]);
|
||||
pixel_row_2[z] = __REV16(pixel_row_2[z]);
|
||||
pixel_row_3[z] = __REV16(pixel_row_3[z]);
|
||||
|
||||
long r_pixel_row_0 = (pixel_row_0[z] >> 11) & 0x1f001f;
|
||||
long r_pixel_row_1 = (pixel_row_1[z] >> 11) & 0x1f001f;
|
||||
long r_pixel_row_2 = (pixel_row_2[z] >> 11) & 0x1f001f;
|
||||
@ -3216,12 +3189,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int pixel_2 = IMAGE_GET_RGB565_PIXEL_FAST(src_row_ptr_2, pixel_x_offests[z]);
|
||||
int pixel_3 = IMAGE_GET_RGB565_PIXEL_FAST(src_row_ptr_3, pixel_x_offests[z]);
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixel_0 = __REV16(pixel_0);
|
||||
pixel_1 = __REV16(pixel_1);
|
||||
pixel_2 = __REV16(pixel_2);
|
||||
pixel_3 = __REV16(pixel_3);
|
||||
|
||||
int r0 = pixel_0 >> 11;
|
||||
int r1 = pixel_1 >> 11;
|
||||
int r2 = pixel_2 >> 11;
|
||||
@ -3549,12 +3516,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
pixel_01 = src_row_ptr_1[src_x_index]; pixel_11 = src_row_ptr_1[src_x_index_p_1];
|
||||
}
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixel_00 = __REV16(pixel_00);
|
||||
pixel_10 = __REV16(pixel_10);
|
||||
pixel_01 = __REV16(pixel_01);
|
||||
pixel_11 = __REV16(pixel_11);
|
||||
|
||||
const long mask_r = 0x7c007c00, mask_g = 0x07e007e0, mask_b = 0x001f001f;
|
||||
const long avg_rb = 0x4010, avg_g = 0x200;
|
||||
|
||||
@ -3582,9 +3543,6 @@ void imlib_draw_image(image_t *dst_img, image_t *src_img, int dst_x_start, int d
|
||||
int g_out = __SMLAD(smuad_x, g, avg_g) >> 5;
|
||||
int pixel = ((rb_out << 1) & 0xf800) | (g_out & 0x07e0) | (rb_out & 0x001f);
|
||||
|
||||
// RGB565 byte reversal fix
|
||||
pixel = __REV16(pixel);
|
||||
|
||||
IMAGE_PUT_RGB565_PIXEL_FAST(dst_row_ptr, dst_x, pixel);
|
||||
|
||||
// Increment offsets
|
||||
|
||||
@ -81,9 +81,9 @@ void gif_add_frame(FIL *fp, image_t *img, uint16_t delay)
|
||||
write_byte(fp, 0x80); // clear code
|
||||
for (int x=0; x<block_size; x++) {
|
||||
int pixel = ((uint16_t *) img->pixels)[(y*BLOCK_SIZE)+x];
|
||||
int red = IM_R565(pixel)>>3;
|
||||
int green = IM_G565(pixel)>>3;
|
||||
int blue = IM_B565(pixel)>>3;
|
||||
int red = COLOR_RGB565_TO_R5(pixel)>>3;
|
||||
int green = COLOR_RGB565_TO_G6(pixel)>>3;
|
||||
int blue = COLOR_RGB565_TO_B5(pixel)>>3;
|
||||
write_byte(fp, (red<<5) | (green<<2) | blue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,16 +353,6 @@ int8_t imlib_rgb565_to_b(uint16_t pixel)
|
||||
return fast_floorf(200 * (y-z));
|
||||
}
|
||||
|
||||
int8_t imlib_rgb565_to_y(uint16_t pixel)
|
||||
{
|
||||
int r = COLOR_RGB565_TO_R8(pixel);
|
||||
int g = COLOR_RGB565_TO_G8(pixel);
|
||||
int b = COLOR_RGB565_TO_B8(pixel);
|
||||
|
||||
return (int8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15) - 128; // .299*r + .587*g + .114*b
|
||||
// return fast_floorf((r * +0.299000f) + (g * +0.587000f) + (b * +0.114000f)) - 128;
|
||||
}
|
||||
|
||||
int8_t imlib_rgb565_to_u(uint16_t pixel)
|
||||
{
|
||||
int r = COLOR_RGB565_TO_R8(pixel);
|
||||
@ -474,10 +464,7 @@ void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uin
|
||||
}
|
||||
|
||||
}
|
||||
r = IM_R825(r);
|
||||
g = IM_G826(g);
|
||||
b = IM_B825(b);
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R8_G8_B8_TO_RGB565(r, g, b);
|
||||
} // for x
|
||||
} else { // faster way
|
||||
//
|
||||
@ -520,7 +507,7 @@ void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uin
|
||||
b = ((l0 & 0xff) + (l2 & 0xff)) >> 4; // left edge pixel
|
||||
g = (l1 & 0xff) >> 2;
|
||||
r = (l1 & 0xff00) >> 11;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b); // first col is treated differently
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b); // first col is treated differently
|
||||
for (int x = xoffs+1; x < xoffs+w-1; x+=2) { // 'middle' pixels can use neighbors from 3x3 grid
|
||||
l0 |= (s[-w2] << 16); // shift last pixel pairs into upper 16 bits
|
||||
l1 |= (s[0] << 16); // of the 3 line variables
|
||||
@ -529,23 +516,23 @@ void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uin
|
||||
r = (l1 & 0xff00) >> 11; // (1, 0) red pixel at current-left
|
||||
g = (((l1 >> 16) & 0xff) + (l1 & 0xff) + ((l0 >> 8) & 0xff) + ((l2 >> 8) & 0xff)) >> 4;
|
||||
b = ((l0 & 0xff) + (l2 & 0xff) + ((l0 >> 16) & 0xff) + ((l2 >> 16) & 0xff)) >> 5;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
g = (l1 & 0xff0000) >> 18; // (0,0) green pixel at current-right
|
||||
b = (((l0 >> 16) & 0xff) + ((l2 >> 16) & 0xff)) >> 4;
|
||||
r = (((l1 >> 8) & 0xff) + (l1 >> 24)) >> 4;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
// prepare for the next set of source pixels
|
||||
l0 >>= 16; l1 >>= 16; l2 >>= 16; // L-CL-CR-R becomes L-CL-0-0
|
||||
} // for x
|
||||
// last col
|
||||
g = ((l0 >> 8) + (l2 >> 8)) >> 3; // re-use blue from last pixel in loop
|
||||
r = (l1 >> 11);
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
} else { // even lines (B G B G B G)
|
||||
b = (l1 & 0xff) >> 3;
|
||||
g = ((l0 & 0xff) + (l2 & 0xff)) >> 3;
|
||||
r = ((l0 & 0xff00) + (l2 & 0xff00)) >> 12; // first pixel is different
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
for (int x = xoffs+1; x < xoffs+w-1; x+=2) { // middle part
|
||||
l0 |= (s[-w2] << 16); // grab 3 more pairs of pixels and put in upper 16-bits
|
||||
l1 |= (s[0] << 16);
|
||||
@ -554,18 +541,18 @@ void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uin
|
||||
g = (l1 & 0xff00) >> 10; // (1, 0) green pixel at current-left
|
||||
b = ((l1 & 0xff) + ((l1 >> 16) & 0xff)) >> 4;
|
||||
r = ((l0 & 0xff00) + (l2 & 0xff00)) >> 12;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
b = (l1 & 0xff0000) >> 19; // (0,0) blue pixel at current-right
|
||||
g = (((l1 >> 8) & 0xff) + (l1 >> 24) + ((l0 >> 16) & 0xff) + ((l2 >> 16) & 0xff)) >> 4;
|
||||
r = (((l0 >> 8) & 0xff) + (l0 >> 24) + ((l2 >> 8) & 0xff) + (l2 >> 24)) >> 5;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b);
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b);
|
||||
// prepare for the next set of source pixels
|
||||
l0 >>= 16; l1 >>= 16; l2 >>= 16; // L-CL-CR-R becomes L-CL-0-0
|
||||
} // for x
|
||||
// last col
|
||||
g = (l1 >> 10); // re-use blue pixel from last column of loop
|
||||
r = ((l0 >> 8) + (l2 >> 8)) >> 4;
|
||||
*rgbbuf++ = IM_RGB565(r, g, b); // last pixel
|
||||
*rgbbuf++ = COLOR_R5_G6_B5_TO_RGB565(r, g, b); // last pixel
|
||||
} // even lines
|
||||
} // faster way
|
||||
} // for y
|
||||
|
||||
@ -223,49 +223,59 @@ color_thresholds_list_lnk_data_t;
|
||||
#define COLOR_B_MIN -128
|
||||
#define COLOR_B_MAX 127
|
||||
|
||||
#define COLOR_Y_MIN -128
|
||||
#define COLOR_Y_MAX 127
|
||||
#define COLOR_Y_MIN 0
|
||||
#define COLOR_Y_MAX 255
|
||||
#define COLOR_U_MIN -128
|
||||
#define COLOR_U_MAX 127
|
||||
#define COLOR_V_MIN -128
|
||||
#define COLOR_V_MAX 127
|
||||
|
||||
extern const uint8_t rb528_table[32];
|
||||
extern const uint8_t g628_table[64];
|
||||
|
||||
#define COLOR_R5_TO_R8(color) rb528_table[color]
|
||||
#define COLOR_G6_TO_G8(color) g628_table[color]
|
||||
#define COLOR_B5_TO_B8(color) rb528_table[color]
|
||||
|
||||
extern const uint8_t rb825_table[256];
|
||||
extern const uint8_t g826_table[256];
|
||||
|
||||
#define COLOR_R8_TO_R5(color) rb825_table[color]
|
||||
#define COLOR_G8_TO_G6(color) g826_table[color]
|
||||
#define COLOR_B8_TO_B5(color) rb825_table[color]
|
||||
|
||||
// RGB565 Stuff //
|
||||
|
||||
#define COLOR_RGB565_TO_R5(pixel) (((pixel) >> 3) & 0x1F)
|
||||
#define COLOR_RGB565_TO_G6(pixel) \
|
||||
#define COLOR_RGB565_TO_R5(pixel) (((pixel) >> 11) & 0x1F)
|
||||
#define COLOR_RGB565_TO_R8(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) _pixel = (pixel); \
|
||||
((_pixel & 0x07) << 3) | (_pixel >> 13); \
|
||||
})
|
||||
#define COLOR_RGB565_TO_B5(pixel) (((pixel) >> 8) & 0x1F)
|
||||
#define COLOR_RGB565_TO_R8(pixel) COLOR_R5_TO_R8(COLOR_RGB565_TO_R5(pixel))
|
||||
#define COLOR_RGB565_TO_G8(pixel) COLOR_G6_TO_G8(COLOR_RGB565_TO_G6(pixel))
|
||||
#define COLOR_RGB565_TO_B8(pixel) COLOR_B5_TO_B8(COLOR_RGB565_TO_B5(pixel))
|
||||
|
||||
#define COLOR_R5_G6_B5_TO_RGB565(r5, g6, b5) \
|
||||
({ \
|
||||
__typeof__ (r5) _r5 = (r5); \
|
||||
__typeof__ (g6) _g6 = (g6); \
|
||||
__typeof__ (b5) _b5 = (b5); \
|
||||
__REV16((_r5 << 11) | (_g6 << 5) | _b5); \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = (__pixel >> 8) & 0xF8; \
|
||||
__pixel | (__pixel >> 5); \
|
||||
})
|
||||
|
||||
#define COLOR_R8_G8_B8_TO_RGB565(r8, g8, b8) COLOR_R5_G6_B5_TO_RGB565(COLOR_R8_TO_R5(r8), COLOR_G8_TO_G6(g8), COLOR_B8_TO_B5(b8))
|
||||
#define COLOR_RGB565_TO_G6(pixel) (((pixel) >> 5) & 0x3F)
|
||||
#define COLOR_RGB565_TO_G8(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = (__pixel >> 3) & 0xFC; \
|
||||
__pixel | (__pixel >> 6); \
|
||||
})
|
||||
|
||||
#define COLOR_RGB565_TO_B5(pixel) ((pixel) & 0x1F)
|
||||
#define COLOR_RGB565_TO_B8(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = (__pixel << 3) & 0xF8; \
|
||||
__pixel | (__pixel >> 5); \
|
||||
})
|
||||
|
||||
#define COLOR_R5_G6_B5_TO_RGB565(r5, g6, b5) (((r5) << 11) | ((g6) << 5) | (b5))
|
||||
#define COLOR_R8_G8_B8_TO_RGB565(r8, g8, b8) ((((r8) & 0xF8) << 8) | (((g8) & 0xFC) << 3) | ((b8) >> 3))
|
||||
|
||||
#define COLOR_RGB888_TO_Y(r8, g8, b8) ((((r8) * 38) + ((g8) * 75) + ((b8) * 15)) >> 7) // 0.299R + 0.587G + 0.114B
|
||||
#define COLOR_RGB565_TO_Y(rgb565) \
|
||||
({ \
|
||||
__typeof__ (rgb565) __rgb565 = (rgb565); \
|
||||
int r = COLOR_RGB565_TO_R8(__rgb565); \
|
||||
int g = COLOR_RGB565_TO_G8(__rgb565); \
|
||||
int b = COLOR_RGB565_TO_B8(__rgb565); \
|
||||
COLOR_RGB888_TO_Y(r, g, b); \
|
||||
})
|
||||
|
||||
#define COLOR_Y_TO_RGB888(pixel) ((pixel) * 0x010101)
|
||||
#define COLOR_Y_TO_RGB565(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
int __rb_pixel = (__pixel >> 3) & 0x1F; \
|
||||
(__rb_pixel * 0x0801) + ((__pixel << 3) & 0x7E0); \
|
||||
})
|
||||
|
||||
extern const int8_t lab_table[196608];
|
||||
extern const int8_t yuv_table[196608];
|
||||
@ -281,59 +291,13 @@ extern const int8_t yuv_table[196608];
|
||||
#endif
|
||||
|
||||
#ifdef IMLIB_ENABLE_YUV_LUT
|
||||
#define COLOR_RGB565_TO_Y(pixel) yuv_table[(pixel) * 3]
|
||||
#define COLOR_RGB565_TO_U(pixel) yuv_table[((pixel) * 3) + 1]
|
||||
#define COLOR_RGB565_TO_V(pixel) yuv_table[((pixel) * 3) + 2]
|
||||
#else
|
||||
#define COLOR_RGB565_TO_Y(pixel) imlib_rgb565_to_y(pixel)
|
||||
#define COLOR_RGB565_TO_U(pixel) imlib_rgb565_to_u(pixel)
|
||||
#define COLOR_RGB565_TO_V(pixel) imlib_rgb565_to_v(pixel)
|
||||
#endif
|
||||
|
||||
#define RGB565_TO_R8_FAST(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = __pixel & 0xF8; /* RGB565 byte reversal fix */ \
|
||||
__pixel | (__pixel >> 5); \
|
||||
})
|
||||
|
||||
#define RGB565_TO_G8_FAST(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = (__REV16(__pixel) >> 3) & 0xFC; /* RGB565 byte reversal fix */ \
|
||||
__pixel | (__pixel >> 6); \
|
||||
})
|
||||
|
||||
#define RGB565_TO_B8_FAST(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
__pixel = (__pixel >> 5) & 0xF8; /* RGB565 byte reversal fix */ \
|
||||
__pixel | (__pixel >> 5); \
|
||||
})
|
||||
|
||||
#define RGB565_TO_Y_FAST(rgb565) \
|
||||
({ \
|
||||
__typeof__ (rgb565) __rgb565 = (rgb565); \
|
||||
int r = RGB565_TO_R8_FAST(__rgb565); \
|
||||
int g = RGB565_TO_G8_FAST(__rgb565); \
|
||||
int b = RGB565_TO_B8_FAST(__rgb565); \
|
||||
((r * 38) + (g * 75) + (b * 15)) >> 7; /* 0.299R + 0.587G + 0.114B */ \
|
||||
})
|
||||
|
||||
#define Y_TO_RGB565_FAST(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
int __rb_pixel = (__pixel >> 3) & 0x3F; \
|
||||
int __rgb_pixel = (__rb_pixel * 0x0801) + ((__pixel << 3) & 0x7E0); \
|
||||
__REV16(__rgb_pixel); /* RGB565 byte reversal fix */ \
|
||||
})
|
||||
|
||||
#define Y_TO_RGB888_FAST(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) __pixel = (pixel); \
|
||||
pixel * 0x010101; \
|
||||
})
|
||||
|
||||
#define COLOR_LAB_TO_RGB565(l, a, b) imlib_lab_to_rgb(l, a, b)
|
||||
#define COLOR_YUV_TO_RGB565(y, u, v) imlib_yuv_to_rgb((y) + 128, u, v)
|
||||
|
||||
@ -386,15 +350,15 @@ extern const int8_t yuv_table[196608];
|
||||
IM_GET_RAW_PIXEL(img, __x+1, __y+1)) >> 2; \
|
||||
} \
|
||||
} \
|
||||
r = IM_R825(r); \
|
||||
g = IM_G826(g); \
|
||||
b = IM_B825(b); \
|
||||
r = r >> 3; \
|
||||
g = g >> 2; \
|
||||
b = b >> 3; \
|
||||
})
|
||||
|
||||
#define COLOR_BINARY_TO_GRAYSCALE(pixel) ((pixel) * COLOR_GRAYSCALE_MAX)
|
||||
#define COLOR_BINARY_TO_RGB565(pixel) COLOR_YUV_TO_RGB565(((pixel) ? 127 : -128), 0, 0)
|
||||
#define COLOR_RGB565_TO_BINARY(pixel) (COLOR_RGB565_TO_Y(pixel) > (((COLOR_Y_MAX - COLOR_Y_MIN) / 2) + COLOR_Y_MIN))
|
||||
#define COLOR_RGB565_TO_GRAYSCALE(pixel) (COLOR_RGB565_TO_Y(pixel) + 128)
|
||||
#define COLOR_RGB565_TO_GRAYSCALE(pixel) COLOR_RGB565_TO_Y(pixel)
|
||||
#define COLOR_GRAYSCALE_TO_BINARY(pixel) ((pixel) > (((COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN) / 2) + COLOR_GRAYSCALE_MIN))
|
||||
#define COLOR_GRAYSCALE_TO_RGB565(pixel) COLOR_YUV_TO_RGB565(((pixel) - 128), 0, 0)
|
||||
|
||||
@ -531,66 +495,6 @@ bool image_get_mask_pixel(image_t *ptr, int x, int y);
|
||||
((uint16_t *) _image->data)[(_image->w * _y) + _x] = _v; \
|
||||
})
|
||||
|
||||
#ifdef __arm__
|
||||
#define IMAGE_REV_RGB565_PIXEL(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) _pixel = (pixel); \
|
||||
__REV16(_pixel); \
|
||||
})
|
||||
#else
|
||||
#define IMAGE_REV_RGB565_PIXEL(pixel) \
|
||||
({ \
|
||||
__typeof__ (pixel) _pixel = (pixel); \
|
||||
((_pixel >> 8) | (_pixel << 8)) & 0xFFFF; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define IMAGE_COMPUTE_TARGET_SIZE_SCALE_FACTOR(target_size, source_rect) \
|
||||
__typeof__ (target_size) _target_size = (target_size); \
|
||||
__typeof__ (source_rect) _source_rect = (source_rect); \
|
||||
int IMAGE_X_SOURCE_OFFSET = _source_rect->p.x; \
|
||||
int IMAGE_Y_SOURCE_OFFSET = _source_rect->p.y; \
|
||||
int IMAGE_X_TARGET_OFFSET = 0; \
|
||||
int IMAGE_Y_TARGET_OFFSET = 0; \
|
||||
float IMAGE_X_RATIO = ((float) _source_rect->s.w) / ((float) _target_size->w); \
|
||||
float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_size->h); \
|
||||
({ 0; })
|
||||
|
||||
#define IMAGE_COMPUTE_TARGET_RECT_SCALE_FACTOR(target_rect, source_rect) \
|
||||
__typeof__ (target_rect) _target_rect = (target_rect); \
|
||||
__typeof__ (source_rect) _source_rect = (source_rect); \
|
||||
int IMAGE_X_SOURCE_OFFSET = _source_rect->p.x; \
|
||||
int IMAGE_Y_SOURCE_OFFSET = _source_rect->p.y; \
|
||||
int IMAGE_X_TARGET_OFFSET = _target_rect->p.x; \
|
||||
int IMAGE_Y_TARGET_OFFSET = _target_rect->p.y; \
|
||||
float IMAGE_X_RATIO = ((float) _source_rect->s.w) / ((float) _target_rect->s.w); \
|
||||
float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_rect->s.h); \
|
||||
({ 0; })
|
||||
|
||||
#define IMAGE_GET_SCALED_BINARY_PIXEL(image, x, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (x) _x = (x); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
IMAGE_GET_BINARY_PIXEL(_image, ((size_t) ((IMAGE_X_RATIO * (_x - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET, ((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_SCALED_GRAYSCALE_PIXEL(image, x, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (x) _x = (x); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
IMAGE_GET_GRAYSCALE_PIXEL(_image, ((size_t) ((IMAGE_X_RATIO * (_x - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET, ((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_SCALED_RGB565_PIXEL(image, x, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (x) _x = (x); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
IMAGE_GET_RGB565_PIXEL(_image, ((size_t) ((IMAGE_X_RATIO * (_x - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET, ((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET); \
|
||||
})
|
||||
|
||||
// Fast Stuff //
|
||||
|
||||
#define IMAGE_COMPUTE_BINARY_PIXEL_ROW_PTR(image, y) \
|
||||
@ -600,13 +504,6 @@ float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_rect->s.h);
|
||||
((uint32_t *) _image->data) + (((_image->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * _y); \
|
||||
})
|
||||
|
||||
#define IMAGE_INC_BINARY_PIXEL_ROW_PTR(row_ptr, image) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
__typeof__ (image) _image = (image); \
|
||||
_row_ptr + ((_image->w + UINT32_T_MASK) >> UINT32_T_SHIFT); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_BINARY_PIXEL_FAST(row_ptr, x) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
@ -645,13 +542,6 @@ float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_rect->s.h);
|
||||
((uint8_t *) _image->data) + (_image->w * _y); \
|
||||
})
|
||||
|
||||
#define IMAGE_INC_GRAYSCALE_PIXEL_ROW_PTR(row_ptr, image) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
__typeof__ (image) _image = (image); \
|
||||
row_ptr + _image->w; \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_GRAYSCALE_PIXEL_FAST(row_ptr, x) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
@ -674,13 +564,6 @@ float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_rect->s.h);
|
||||
((uint16_t *) _image->data) + (_image->w * _y); \
|
||||
})
|
||||
|
||||
#define IMAGE_INC_RGB565_PIXEL_ROW_PTR(row_ptr, image) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
__typeof__ (image) _image = (image); \
|
||||
row_ptr + _image->w; \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_RGB565_PIXEL_FAST(row_ptr, x) \
|
||||
({ \
|
||||
__typeof__ (row_ptr) _row_ptr = (row_ptr); \
|
||||
@ -696,92 +579,8 @@ float IMAGE_Y_RATIO = ((float) _source_rect->s.h) / ((float) _target_rect->s.h);
|
||||
_row_ptr[_x] = _v; \
|
||||
})
|
||||
|
||||
#define IMAGE_COMPUTE_SCALED_BINARY_PIXEL_ROW_PTR(image, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
((uint32_t *) _image->data) + (((_image->w + UINT32_T_MASK) >> UINT32_T_SHIFT) * (((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET)); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_SCALED_BINARY_PIXEL_FAST(row_ptr, x) IMAGE_GET_BINARY_PIXEL_FAST((row_ptr), ((size_t) ((IMAGE_X_RATIO * ((x) - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET)
|
||||
|
||||
#define IMAGE_COMPUTE_SCALED_GRAYSCALE_PIXEL_ROW_PTR(image, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
((uint8_t *) _image->data) + (_image->w * (((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET)); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_SCALED_GRAYSCALE_PIXEL_FAST(row_ptr, x) IMAGE_GET_GRAYSCALE_PIXEL_FAST((row_ptr), ((size_t) ((IMAGE_X_RATIO * ((x) - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET)
|
||||
|
||||
#define IMAGE_COMPUTE_SCALED_RGB565_PIXEL_ROW_PTR(image, y) \
|
||||
({ \
|
||||
__typeof__ (image) _image = (image); \
|
||||
__typeof__ (y) _y = (y); \
|
||||
((uint16_t *) _image->data) + (_image->w * (((size_t) ((IMAGE_Y_RATIO * (_y - IMAGE_Y_TARGET_OFFSET)) + 0.5)) + IMAGE_Y_SOURCE_OFFSET)); \
|
||||
})
|
||||
|
||||
#define IMAGE_GET_SCALED_RGB565_PIXEL_FAST(row_ptr, x) IMAGE_GET_RGB565_PIXEL_FAST((row_ptr), ((size_t) ((IMAGE_X_RATIO * ((x) - IMAGE_X_TARGET_OFFSET)) + 0.5)) + IMAGE_X_SOURCE_OFFSET)
|
||||
|
||||
// Old Image Macros - Will be refactor and removed. But, only after making sure through testing new macros work.
|
||||
|
||||
#define IM_SWAP16(x) __REV16(x) // Swap bottom two chars in short.
|
||||
#define IM_SWAP32(x) __REV32(x) // Swap bottom two shorts in long.
|
||||
|
||||
// RGB565 to RGB888 conversion.
|
||||
extern const uint8_t rb528_table[32];
|
||||
extern const uint8_t g628_table[64];
|
||||
|
||||
#define IM_R528(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
rb528_table[_p]; })
|
||||
|
||||
#define IM_G628(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
g628_table[_p]; })
|
||||
|
||||
#define IM_B528(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
rb528_table[_p]; })
|
||||
|
||||
// RGB888 to RGB565 conversion.
|
||||
extern const uint8_t rb825_table[256];
|
||||
extern const uint8_t g826_table[256];
|
||||
|
||||
#define IM_R825(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
rb825_table[_p]; })
|
||||
|
||||
#define IM_G826(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
g826_table[_p]; })
|
||||
|
||||
#define IM_B825(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
rb825_table[_p]; })
|
||||
|
||||
// Split RGB565 values (note the RGB565 value is byte reversed).
|
||||
|
||||
#define IM_R565(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
((_p)>>3)&0x1F; })
|
||||
|
||||
#define IM_G565(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
(((_p)&0x07)<<3)|((_p)>>13); })
|
||||
|
||||
#define IM_B565(p) \
|
||||
({ __typeof__ (p) _p = (p); \
|
||||
((_p)>>8)&0x1F; })
|
||||
|
||||
// Merge RGB565 values (note the RGB565 value is byte reversed).
|
||||
|
||||
#define IM_RGB565(r, g, b) \
|
||||
({ __typeof__ (r) _r = (r); \
|
||||
__typeof__ (g) _g = (g); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
((_r)<<3)|((_g)>>3)|((_g)<<13)|((_b)<<8); })
|
||||
|
||||
// Image kernels
|
||||
extern const int8_t kernel_gauss_3[9];
|
||||
extern const int8_t kernel_gauss_5[25];
|
||||
@ -914,7 +713,7 @@ extern const int kernel_high_pass_3[9];
|
||||
(_img0->w==_img1->w)&&(_img0->h==_img1->h)&&(_img0->bpp==_img1->bpp); })
|
||||
|
||||
#define IM_TO_GS_PIXEL(img, x, y) \
|
||||
(img->bpp == 1 ? img->pixels[((y)*img->w)+(x)] : (COLOR_RGB565_TO_Y(((uint16_t*)img->pixels)[((y)*img->w)+(x)]) + 128))
|
||||
(img->bpp == 1 ? img->pixels[((y)*img->w)+(x)] : COLOR_RGB565_TO_Y(((uint16_t*)img->pixels)[((y)*img->w)+(x)]) )
|
||||
|
||||
typedef struct simple_color {
|
||||
uint8_t G; // Gray
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include <stdint.h>
|
||||
#ifdef IMLIB_ENABLE_INVARIANT_TABLE
|
||||
const uint16_t invariant_table[65536] = {
|
||||
0xAA52, 0x483C, 0xE51D, 0xA316, 0x220F, 0x610F, 0xA107, 0xAA52, 0x6B5A, 0x083C, 0xA525, 0x8316, 0x020F, 0x610F, 0xA107, 0xAA52,
|
||||
0x2B5A, 0xC943, 0x8525, 0x6316, 0x020F, 0x610F, 0xA107, 0xAA52, 0xEB61, 0x8943, 0x462D, 0x441E, 0xE20E, 0x420F, 0x8107, 0xAA52,
|
||||
@ -4098,4 +4097,3 @@ const uint16_t invariant_table[65536] = {
|
||||
0x2BA0, 0x4C90, 0x8C88, 0xEC78, 0x6C71, 0xEB61, 0x6B5A, 0xEA52, 0x2BA0, 0x4C90, 0x8C88, 0xEC80, 0x4C71, 0xCB69, 0x4B5A, 0xCA52,
|
||||
0x2BA0, 0x4B90, 0x8C88, 0xEC80, 0x4C71, 0xCB69, 0x4B5A, 0xCA52, 0x2BA0, 0x4B98, 0x8C88, 0xCC80, 0x4C71, 0xAC69, 0x2B62, 0xAA52
|
||||
};
|
||||
#endif //IMLIB_ENABLE_INVARIANT_TABLE
|
||||
|
||||
@ -252,9 +252,9 @@ static uint8_t *get_mcu()
|
||||
pPixels = &jpeg_enc.pixels16[(y * jpeg_enc.img_w) + jpeg_enc.x_offset];
|
||||
for (int x=jpeg_enc.x_offset; x<(jpeg_enc.x_offset + dx); x++, idx++) {
|
||||
pixel = *pPixels++; // get RGB565 pixel
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel); // extract R8/G8/B8
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
Y0[idx] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15); // .299*r + .587*g + .114*b
|
||||
CB[idx] = (uint8_t)(((b << 14) - (r * 5529) - (g * 10855)) >> 15) -128; // -0.168736*r + -0.331264*g + 0.5*b
|
||||
@ -1047,9 +1047,9 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
|
||||
pY = &YDU[(ty*8)]; pU = &UDU[ty*8]; pV=&VDU[ty*8];
|
||||
for (int tx=0; tx<dx; tx++) { // columns
|
||||
pixel = *pRow++;
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel);
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
*pY++ = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15) -128; // .299*r + .587*g + .114*b
|
||||
*pU++ = (uint8_t)(((b << 14) - (r * 5529) - (g * 10855)) >> 15); // -0.168736*r + -0.331264*g + 0.5*b
|
||||
@ -1090,17 +1090,17 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
|
||||
pY += (64-8);
|
||||
|
||||
pixel = pRow[0]; // left
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel);
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[0] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15) -128; // .299*r + .587*g + .114*b
|
||||
*pU++ = (uint8_t)(((b << 14) - (r * 5529) - (g * 10855)) >> 15); // -0.168736*r + -0.331264*g + 0.5*b
|
||||
*pV++ = (uint8_t)(((r << 14) - (g * 13682) - (b * 2664)) >> 15); // 0.5*r + -0.418688*g + -0.081312*b
|
||||
pixel = pRow[1]; // right
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel);
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[1] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15)-128; // .299*r + .587*g + .114*b
|
||||
|
||||
@ -1150,31 +1150,31 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
|
||||
pY += (64-8);
|
||||
|
||||
pixel = pRow[0]; // top left
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel); // extract R8/G8/B8
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[0] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15) -128; // .299*r + .587*g + .114*b
|
||||
pU[0] = (uint8_t)(((b << 14) - (r * 5529) - (g * 10855)) >> 15); // -0.168736*r + -0.331264*g + 0.5*b
|
||||
pV[0] = (uint8_t)(((r << 14) - (g * 13682) - (b * 2664)) >> 15); // 0.5*r + -0.418688*g + -0.081312*b
|
||||
pixel = pRow[1]; // top right
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel); // extract R8/G8/B8
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[1] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15)-128; // .299*r + .587*g + .114*b
|
||||
|
||||
pixel = pRow[src->w]; // bottom left
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel); // extract R8/G8/B8
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[8] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15)-128; // .299*r + .587*g + .114*b
|
||||
|
||||
pixel = pRow[1+src->w]; // bottom right
|
||||
r = rb528_table[(pixel >> 3) & 0x1f]; // extract R8/G8/B8
|
||||
g = g628_table[((pixel & 7) << 3) | (pixel >> 13)];
|
||||
b = rb528_table[(pixel >> 8) & 0x1f];
|
||||
r = COLOR_RGB565_TO_R8(pixel); // extract R8/G8/B8
|
||||
g = COLOR_RGB565_TO_G8(pixel);
|
||||
b = COLOR_RGB565_TO_B8(pixel);
|
||||
// faster to keep all calculations in integer math with 15-bit fractions
|
||||
pY[9] = (uint8_t)(((r * 9770) + (g * 19182) + (b * 3736)) >> 15)-128; // .299*r + .587*g + .114*b
|
||||
pY += 2; pU++; pV++; pRow += 2;
|
||||
@ -1293,7 +1293,7 @@ void jpeg_read_geometry(FIL *fp, image_t *img, const char *path, jpg_read_settin
|
||||
for (;;) {
|
||||
uint16_t header;
|
||||
read_word(fp, &header);
|
||||
header = IM_SWAP16(header);
|
||||
header = __REV16(header);
|
||||
if ((0xFFD0 <= header) && (header <= 0xFFD9)) {
|
||||
continue;
|
||||
} else if (((0xFFC0 <= header) && (header <= 0xFFCF))
|
||||
@ -1303,7 +1303,7 @@ void jpeg_read_geometry(FIL *fp, image_t *img, const char *path, jpg_read_settin
|
||||
{
|
||||
uint16_t size;
|
||||
read_word(fp, &size);
|
||||
size = IM_SWAP16(size);
|
||||
size = __REV16(size);
|
||||
if (((0xFFC0 <= header) && (header <= 0xFFC3))
|
||||
|| ((0xFFC5 <= header) && (header <= 0xFFC7))
|
||||
|| ((0xFFC9 <= header) && (header <= 0xFFCB))
|
||||
@ -1312,10 +1312,10 @@ void jpeg_read_geometry(FIL *fp, image_t *img, const char *path, jpg_read_settin
|
||||
read_byte_ignore(fp);
|
||||
uint16_t width;
|
||||
read_word(fp, &width);
|
||||
width = IM_SWAP16(width);
|
||||
width = __REV16(width);
|
||||
uint16_t height;
|
||||
read_word(fp, &height);
|
||||
height = IM_SWAP16(height);
|
||||
height = __REV16(height);
|
||||
rs->jpg_w = img->w = width;
|
||||
rs->jpg_h = img->h = height;
|
||||
rs->jpg_size = img->bpp = f_size(fp);
|
||||
|
||||
32768
src/omv/img/lab_tab.c
32768
src/omv/img/lab_tab.c
File diff suppressed because it is too large
Load Diff
@ -86,9 +86,7 @@ void ppm_read_pixels(FIL *fp, image_t *img, int n_lines, ppm_read_settings_t *rs
|
||||
read_int(fp, &r, rs);
|
||||
read_int(fp, &g, rs);
|
||||
read_int(fp, &b, rs);
|
||||
IM_SET_RGB565_PIXEL(img, j, i, IM_RGB565(IM_R825(r),
|
||||
IM_G826(g),
|
||||
IM_B825(b)));
|
||||
IM_SET_RGB565_PIXEL(img, j, i, COLOR_R8_G8_B8_TO_RGB565(r, g, b));
|
||||
}
|
||||
}
|
||||
} else if (rs->ppm_fmt == '5') {
|
||||
@ -100,9 +98,7 @@ void ppm_read_pixels(FIL *fp, image_t *img, int n_lines, ppm_read_settings_t *rs
|
||||
read_byte(fp, &r);
|
||||
read_byte(fp, &g);
|
||||
read_byte(fp, &b);
|
||||
IM_SET_RGB565_PIXEL(img, j, i, IM_RGB565(IM_R825(r),
|
||||
IM_G826(g),
|
||||
IM_B825(b)));
|
||||
IM_SET_RGB565_PIXEL(img, j, i, COLOR_R8_G8_B8_TO_RGB565(r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,9 +146,9 @@ void ppm_write_subimg(image_t *img, const char *path, rectangle_t *r)
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
int pixel = IM_GET_RGB565_PIXEL(img, (rect.x + j), (rect.y + i));
|
||||
char buff[3];
|
||||
buff[0] = IM_R528(IM_R565(pixel));
|
||||
buff[1] = IM_G628(IM_G565(pixel));
|
||||
buff[2] = IM_B528(IM_B565(pixel));
|
||||
buff[0] = COLOR_RGB565_TO_R8(pixel);
|
||||
buff[1] = COLOR_RGB565_TO_G8(pixel);
|
||||
buff[2] = COLOR_RGB565_TO_B8(pixel);
|
||||
write_data(&fp, buff, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,7 +982,7 @@ static void threshold(struct quirc *q)
|
||||
// to get the effect used below (a fraction of threshold_s-1/threshold_s
|
||||
// The second constant is to reduce the averaged values to compare with the current pixel
|
||||
fracmul2 = (0x100000 * (100 - THRESHOLD_T)) / (200 * threshold_s); // use as many bits as possible without overflowing
|
||||
|
||||
|
||||
for (y = 0; y < q->h; y++) {
|
||||
int row_average[q->w];
|
||||
|
||||
@ -2996,7 +2996,7 @@ void imlib_find_qrcodes(list_t *out, image_t *ptr, rectangle_t *roi)
|
||||
for (int y = roi->y, yy = roi->y + roi->h; y < yy; y++) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(ptr, y);
|
||||
for (int x = roi->x, xx = roi->x + roi->w; x < xx; x++) {
|
||||
*(grayscale_image++) = RGB565_TO_Y_FAST(IMAGE_GET_RGB565_PIXEL_FAST(row_ptr, x));
|
||||
*(grayscale_image++) = COLOR_RGB565_TO_Y(IMAGE_GET_RGB565_PIXEL_FAST(row_ptr, x));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1,69 +1,69 @@
|
||||
#include <stdint.h>
|
||||
const uint16_t rainbow_table[256] = {
|
||||
0x3F06, 0x3F06, 0x5F06, 0x7F06, 0x9F06, 0xBF06, 0xBF06, 0xDF06,
|
||||
0xFF06, 0x1F07, 0x3F07, 0x3F07, 0x5F07, 0x7F07, 0x9F07, 0xBF07,
|
||||
0xBF07, 0xDF07, 0xFF07, 0xFF07, 0xFE07, 0xFE07, 0xFD07, 0xFD07,
|
||||
0xFD07, 0xFC07, 0xFC07, 0xFB07, 0xFB07, 0xFB07, 0xFA07, 0xFA07,
|
||||
0xFA07, 0xF907, 0xF907, 0xF807, 0xF807, 0xF807, 0xF707, 0xF707,
|
||||
0xF607, 0xF607, 0xF607, 0xF507, 0xF507, 0xF407, 0xF407, 0xF407,
|
||||
0xF307, 0xF307, 0xF207, 0xF207, 0xF207, 0xF107, 0xF107, 0xF107,
|
||||
0xF007, 0xF007, 0xEF07, 0xEF07, 0xEF07, 0xEE07, 0xEE07, 0xED07,
|
||||
0xED07, 0xED07, 0xEC07, 0xEC07, 0xEB07, 0xEB07, 0xEB07, 0xEA07,
|
||||
0xEA07, 0xEA07, 0xE907, 0xE907, 0xE807, 0xE807, 0xE807, 0xE707,
|
||||
0xE707, 0xE607, 0xE607, 0xE607, 0xE507, 0xE507, 0xE407, 0xE407,
|
||||
0xE407, 0xE307, 0xE307, 0xE207, 0xE207, 0xE207, 0xE107, 0xE107,
|
||||
0xE107, 0xE007, 0xE007, 0xE00F, 0xE00F, 0xE00F, 0xE017, 0xE017,
|
||||
0xE01F, 0xE01F, 0xE01F, 0xE027, 0xE027, 0xE02F, 0xE02F, 0xE02F,
|
||||
0xE037, 0xE037, 0xE03F, 0xE03F, 0xE03F, 0xE047, 0xE047, 0xE047,
|
||||
0xE04F, 0xE04F, 0xE057, 0xE057, 0xE057, 0xE05F, 0xE05F, 0xE067,
|
||||
0xE067, 0xE067, 0xE06F, 0xE06F, 0xE077, 0xE077, 0xE077, 0xE07F,
|
||||
0xE07F, 0xE087, 0xE087, 0xE087, 0xE08F, 0xE08F, 0xE08F, 0xE097,
|
||||
0xE097, 0xE09F, 0xE09F, 0xE09F, 0xE0A7, 0xE0A7, 0xE0AF, 0xE0AF,
|
||||
0xE0AF, 0xE0B7, 0xE0B7, 0xE0BF, 0xE0BF, 0xE0BF, 0xE0C7, 0xE0C7,
|
||||
0xE0C7, 0xE0CF, 0xE0CF, 0xE0D7, 0xE0D7, 0xE0D7, 0xE0DF, 0xE0DF,
|
||||
0xE0E7, 0xE0E7, 0xE0E7, 0xE0EF, 0xE0EF, 0xE0F7, 0xE0F7, 0xE0F7,
|
||||
0xE0FF, 0xE0FF, 0xC0FF, 0xA0FF, 0x80FF, 0x80FF, 0x60FF, 0x40FF,
|
||||
0x20FF, 0x00FF, 0x00FF, 0xE0FE, 0xC0FE, 0xA0FE, 0x80FE, 0x80FE,
|
||||
0x60FE, 0x40FE, 0x20FE, 0x00FE, 0x00FE, 0xE0FD, 0xC0FD, 0xA0FD,
|
||||
0x80FD, 0x80FD, 0x60FD, 0x40FD, 0x20FD, 0x00FD, 0x00FD, 0xE0FC,
|
||||
0xC0FC, 0xA0FC, 0xA0FC, 0x80FC, 0x60FC, 0x40FC, 0x20FC, 0x20FC,
|
||||
0x00FC, 0xE0FB, 0xC0FB, 0xA0FB, 0xA0FB, 0x80FB, 0x60FB, 0x40FB,
|
||||
0x20FB, 0x20FB, 0x00FB, 0xE0FA, 0xC0FA, 0xA0FA, 0xA0FA, 0x80FA,
|
||||
0x60FA, 0x40FA, 0x20FA, 0x20FA, 0x00FA, 0xE0F9, 0xC0F9, 0xA0F9,
|
||||
0xA0F9, 0x80F9, 0x60F9, 0x40F9, 0x40F9, 0x20F9, 0x00F9, 0xE0F8,
|
||||
0xC0F8, 0xC0F8, 0xA0F8, 0x80F8, 0x60F8, 0x40F8, 0x40F8, 0x20F8
|
||||
0x063F, 0x063F, 0x065F, 0x067F, 0x069F, 0x06BF, 0x06BF, 0x06DF,
|
||||
0x06FF, 0x071F, 0x073F, 0x073F, 0x075F, 0x077F, 0x079F, 0x07BF,
|
||||
0x07BF, 0x07DF, 0x07FF, 0x07FF, 0x07FE, 0x07FE, 0x07FD, 0x07FD,
|
||||
0x07FD, 0x07FC, 0x07FC, 0x07FB, 0x07FB, 0x07FB, 0x07FA, 0x07FA,
|
||||
0x07FA, 0x07F9, 0x07F9, 0x07F8, 0x07F8, 0x07F8, 0x07F7, 0x07F7,
|
||||
0x07F6, 0x07F6, 0x07F6, 0x07F5, 0x07F5, 0x07F4, 0x07F4, 0x07F4,
|
||||
0x07F3, 0x07F3, 0x07F2, 0x07F2, 0x07F2, 0x07F1, 0x07F1, 0x07F1,
|
||||
0x07F0, 0x07F0, 0x07EF, 0x07EF, 0x07EF, 0x07EE, 0x07EE, 0x07ED,
|
||||
0x07ED, 0x07ED, 0x07EC, 0x07EC, 0x07EB, 0x07EB, 0x07EB, 0x07EA,
|
||||
0x07EA, 0x07EA, 0x07E9, 0x07E9, 0x07E8, 0x07E8, 0x07E8, 0x07E7,
|
||||
0x07E7, 0x07E6, 0x07E6, 0x07E6, 0x07E5, 0x07E5, 0x07E4, 0x07E4,
|
||||
0x07E4, 0x07E3, 0x07E3, 0x07E2, 0x07E2, 0x07E2, 0x07E1, 0x07E1,
|
||||
0x07E1, 0x07E0, 0x07E0, 0x0FE0, 0x0FE0, 0x0FE0, 0x17E0, 0x17E0,
|
||||
0x1FE0, 0x1FE0, 0x1FE0, 0x27E0, 0x27E0, 0x2FE0, 0x2FE0, 0x2FE0,
|
||||
0x37E0, 0x37E0, 0x3FE0, 0x3FE0, 0x3FE0, 0x47E0, 0x47E0, 0x47E0,
|
||||
0x4FE0, 0x4FE0, 0x57E0, 0x57E0, 0x57E0, 0x5FE0, 0x5FE0, 0x67E0,
|
||||
0x67E0, 0x67E0, 0x6FE0, 0x6FE0, 0x77E0, 0x77E0, 0x77E0, 0x7FE0,
|
||||
0x7FE0, 0x87E0, 0x87E0, 0x87E0, 0x8FE0, 0x8FE0, 0x8FE0, 0x97E0,
|
||||
0x97E0, 0x9FE0, 0x9FE0, 0x9FE0, 0xA7E0, 0xA7E0, 0xAFE0, 0xAFE0,
|
||||
0xAFE0, 0xB7E0, 0xB7E0, 0xBFE0, 0xBFE0, 0xBFE0, 0xC7E0, 0xC7E0,
|
||||
0xC7E0, 0xCFE0, 0xCFE0, 0xD7E0, 0xD7E0, 0xD7E0, 0xDFE0, 0xDFE0,
|
||||
0xE7E0, 0xE7E0, 0xE7E0, 0xEFE0, 0xEFE0, 0xF7E0, 0xF7E0, 0xF7E0,
|
||||
0xFFE0, 0xFFE0, 0xFFC0, 0xFFA0, 0xFF80, 0xFF80, 0xFF60, 0xFF40,
|
||||
0xFF20, 0xFF00, 0xFF00, 0xFEE0, 0xFEC0, 0xFEA0, 0xFE80, 0xFE80,
|
||||
0xFE60, 0xFE40, 0xFE20, 0xFE00, 0xFE00, 0xFDE0, 0xFDC0, 0xFDA0,
|
||||
0xFD80, 0xFD80, 0xFD60, 0xFD40, 0xFD20, 0xFD00, 0xFD00, 0xFCE0,
|
||||
0xFCC0, 0xFCA0, 0xFCA0, 0xFC80, 0xFC60, 0xFC40, 0xFC20, 0xFC20,
|
||||
0xFC00, 0xFBE0, 0xFBC0, 0xFBA0, 0xFBA0, 0xFB80, 0xFB60, 0xFB40,
|
||||
0xFB20, 0xFB20, 0xFB00, 0xFAE0, 0xFAC0, 0xFAA0, 0xFAA0, 0xFA80,
|
||||
0xFA60, 0xFA40, 0xFA20, 0xFA20, 0xFA00, 0xF9E0, 0xF9C0, 0xF9A0,
|
||||
0xF9A0, 0xF980, 0xF960, 0xF940, 0xF940, 0xF920, 0xF900, 0xF8E0,
|
||||
0xF8C0, 0xF8C0, 0xF8A0, 0xF880, 0xF860, 0xF840, 0xF840, 0xF820
|
||||
};
|
||||
const uint16_t ironbow_table[256] = {
|
||||
0xFFFF, 0xFFFF, 0xDFFF, 0xDEF7, 0xBEF7, 0xBEF7, 0x9EF7, 0x9DEF,
|
||||
0x7DEF, 0x7DEF, 0x5DEF, 0x5CE7, 0x3CE7, 0x3CE7, 0x1CE7, 0x1BDF,
|
||||
0xFBDE, 0xFBDE, 0xDBDE, 0xDAD6, 0xBAD6, 0xBAD6, 0x9AD6, 0x99CE,
|
||||
0x79CE, 0x79CE, 0x59CE, 0x58C6, 0x38C6, 0x38C6, 0x18C6, 0x17BE,
|
||||
0xF7BD, 0xF7BD, 0xD7BD, 0xD6B5, 0xB6B5, 0xB6B5, 0x96B5, 0x96B5,
|
||||
0x75AD, 0x75AD, 0x55AD, 0x55AD, 0x34A5, 0x34A5, 0x14A5, 0x14A5,
|
||||
0xF39C, 0xF39C, 0xD39C, 0xD39C, 0xB294, 0xB294, 0x9294, 0x9294,
|
||||
0x718C, 0x718C, 0x518C, 0x518C, 0x3084, 0x3084, 0x1084, 0x1084,
|
||||
0xEF7B, 0xEF7B, 0xCF7B, 0xCF7B, 0xAE73, 0xAE73, 0x8E73, 0x8E73,
|
||||
0x6D6B, 0x6D6B, 0x4D6B, 0x4D6B, 0x2C63, 0x2C63, 0x0C63, 0x0C63,
|
||||
0xEB5A, 0xEB5A, 0xCB5A, 0xCB5A, 0xAA52, 0xAA52, 0x8A52, 0x8A52,
|
||||
0x694A, 0x694A, 0x494A, 0x494A, 0x294A, 0x2842, 0x0842, 0x0842,
|
||||
0xE841, 0xE739, 0xC739, 0xC739, 0xA739, 0xA631, 0x8631, 0x8631,
|
||||
0x6631, 0x6529, 0x4529, 0x4529, 0x2529, 0x2421, 0x0421, 0x0421,
|
||||
0xE420, 0xE318, 0xC318, 0xC318, 0xA318, 0xA210, 0x8210, 0x8210,
|
||||
0x6210, 0x6108, 0x4108, 0x4108, 0x2108, 0x2000, 0x0000, 0x0000,
|
||||
0x0100, 0x0200, 0x0300, 0x0408, 0x0508, 0x0508, 0x0608, 0x0710,
|
||||
0x0810, 0x0910, 0x0A18, 0x0B18, 0x0C18, 0x0D18, 0x0D20, 0x0E20,
|
||||
0x0F20, 0x0F28, 0x0F30, 0x0F30, 0x0F38, 0x0F38, 0x0F40, 0x0F48,
|
||||
0x1048, 0x1050, 0x1050, 0x1058, 0x1060, 0x1060, 0x1068, 0x1068,
|
||||
0x1170, 0x1178, 0x1178, 0x1180, 0x3180, 0x3188, 0x3190, 0x3190,
|
||||
0x3198, 0x3198, 0x31A0, 0x31A0, 0x31A8, 0x31B0, 0x51B0, 0x51B8,
|
||||
0x51B8, 0x70B8, 0x8FC0, 0xAFC0, 0xAEC0, 0xCDC0, 0xEDC8, 0x0CC9,
|
||||
0x0CC9, 0x2BC9, 0x4AD1, 0x6AD1, 0x69D1, 0x88D9, 0xA8D9, 0xC7D9,
|
||||
0xC6D9, 0xE6D9, 0x05DA, 0x25E2, 0x45E2, 0x44E2, 0x64E2, 0x84E2,
|
||||
0xA4E2, 0xC3E2, 0xE3E2, 0xE3E2, 0x02EB, 0x22EB, 0x42EB, 0x61EB,
|
||||
0x81EB, 0xA1EB, 0xA1EB, 0xC1EB, 0xE1EB, 0x01EC, 0x21EC, 0x41F4,
|
||||
0x62F4, 0x82F4, 0xA2F4, 0xC2F4, 0xE2F4, 0x02F5, 0x02F5, 0x22F5,
|
||||
0x42F5, 0x62F5, 0x82F5, 0xA2F5, 0xC2F5, 0xE2F5, 0xE2F5, 0x03FE,
|
||||
0x23FE, 0x43FE, 0x63FE, 0x83FE, 0xA3FE, 0xC3FE, 0xC4FE, 0xE4FE,
|
||||
0x05FF, 0x26FF, 0x28FF, 0x4AFF, 0x4CFF, 0x4DFF, 0x6FFF, 0x71FF,
|
||||
0x92FF, 0x94FF, 0xB6FF, 0xB7FF, 0xD9FF, 0xDBFF, 0xFDFF, 0xE3FF
|
||||
0xFFFF, 0xFFFF, 0xFFDF, 0xF7DE, 0xF7BE, 0xF7BE, 0xF79E, 0xEF9D,
|
||||
0xEF7D, 0xEF7D, 0xEF5D, 0xE75C, 0xE73C, 0xE73C, 0xE71C, 0xDF1B,
|
||||
0xDEFB, 0xDEFB, 0xDEDB, 0xD6DA, 0xD6BA, 0xD6BA, 0xD69A, 0xCE99,
|
||||
0xCE79, 0xCE79, 0xCE59, 0xC658, 0xC638, 0xC638, 0xC618, 0xBE17,
|
||||
0xBDF7, 0xBDF7, 0xBDD7, 0xB5D6, 0xB5B6, 0xB5B6, 0xB596, 0xB596,
|
||||
0xAD75, 0xAD75, 0xAD55, 0xAD55, 0xA534, 0xA534, 0xA514, 0xA514,
|
||||
0x9CF3, 0x9CF3, 0x9CD3, 0x9CD3, 0x94B2, 0x94B2, 0x9492, 0x9492,
|
||||
0x8C71, 0x8C71, 0x8C51, 0x8C51, 0x8430, 0x8430, 0x8410, 0x8410,
|
||||
0x7BEF, 0x7BEF, 0x7BCF, 0x7BCF, 0x73AE, 0x73AE, 0x738E, 0x738E,
|
||||
0x6B6D, 0x6B6D, 0x6B4D, 0x6B4D, 0x632C, 0x632C, 0x630C, 0x630C,
|
||||
0x5AEB, 0x5AEB, 0x5ACB, 0x5ACB, 0x52AA, 0x52AA, 0x528A, 0x528A,
|
||||
0x4A69, 0x4A69, 0x4A49, 0x4A49, 0x4A29, 0x4228, 0x4208, 0x4208,
|
||||
0x41E8, 0x39E7, 0x39C7, 0x39C7, 0x39A7, 0x31A6, 0x3186, 0x3186,
|
||||
0x3166, 0x2965, 0x2945, 0x2945, 0x2925, 0x2124, 0x2104, 0x2104,
|
||||
0x20E4, 0x18E3, 0x18C3, 0x18C3, 0x18A3, 0x10A2, 0x1082, 0x1082,
|
||||
0x1062, 0x0861, 0x0841, 0x0841, 0x0821, 0x0020, 0x0000, 0x0000,
|
||||
0x0001, 0x0002, 0x0003, 0x0804, 0x0805, 0x0805, 0x0806, 0x1007,
|
||||
0x1008, 0x1009, 0x180A, 0x180B, 0x180C, 0x180D, 0x200D, 0x200E,
|
||||
0x200F, 0x280F, 0x300F, 0x300F, 0x380F, 0x380F, 0x400F, 0x480F,
|
||||
0x4810, 0x5010, 0x5010, 0x5810, 0x6010, 0x6010, 0x6810, 0x6810,
|
||||
0x7011, 0x7811, 0x7811, 0x8011, 0x8031, 0x8831, 0x9031, 0x9031,
|
||||
0x9831, 0x9831, 0xA031, 0xA031, 0xA831, 0xB031, 0xB051, 0xB851,
|
||||
0xB851, 0xB870, 0xC08F, 0xC0AF, 0xC0AE, 0xC0CD, 0xC8ED, 0xC90C,
|
||||
0xC90C, 0xC92B, 0xD14A, 0xD16A, 0xD169, 0xD988, 0xD9A8, 0xD9C7,
|
||||
0xD9C6, 0xD9E6, 0xDA05, 0xE225, 0xE245, 0xE244, 0xE264, 0xE284,
|
||||
0xE2A4, 0xE2C3, 0xE2E3, 0xE2E3, 0xEB02, 0xEB22, 0xEB42, 0xEB61,
|
||||
0xEB81, 0xEBA1, 0xEBA1, 0xEBC1, 0xEBE1, 0xEC01, 0xEC21, 0xF441,
|
||||
0xF462, 0xF482, 0xF4A2, 0xF4C2, 0xF4E2, 0xF502, 0xF502, 0xF522,
|
||||
0xF542, 0xF562, 0xF582, 0xF5A2, 0xF5C2, 0xF5E2, 0xF5E2, 0xFE03,
|
||||
0xFE23, 0xFE43, 0xFE63, 0xFE83, 0xFEA3, 0xFEC3, 0xFEC4, 0xFEE4,
|
||||
0xFF05, 0xFF26, 0xFF28, 0xFF4A, 0xFF4C, 0xFF4D, 0xFF6F, 0xFF71,
|
||||
0xFF92, 0xFF94, 0xFFB6, 0xFFB7, 0xFFD9, 0xFFDB, 0xFFFD, 0xFFE3
|
||||
};
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
#include <stdint.h>
|
||||
const uint8_t rb528_table[32] = {
|
||||
0, 8, 16, 25, 33, 41, 49, 58,
|
||||
66, 74, 82, 90, 99, 107, 115, 123,
|
||||
132, 140, 148, 156, 165, 173, 181, 189,
|
||||
197, 206, 214, 222, 230, 239, 247, 255
|
||||
};
|
||||
const uint8_t g628_table[64] = {
|
||||
0, 4, 8, 12, 16, 20, 24, 28,
|
||||
32, 36, 40, 45, 49, 53, 57, 61,
|
||||
65, 69, 73, 77, 81, 85, 89, 93,
|
||||
97, 101, 105, 109, 113, 117, 121, 125,
|
||||
130, 134, 138, 142, 146, 150, 154, 158,
|
||||
162, 166, 170, 174, 178, 182, 186, 190,
|
||||
194, 198, 202, 206, 210, 215, 219, 223,
|
||||
227, 231, 235, 239, 243, 247, 251, 255
|
||||
};
|
||||
const uint8_t rb825_table[256] = {
|
||||
0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 11,
|
||||
11, 11, 11, 11, 11, 11, 11, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13,
|
||||
14, 14, 14, 14, 14, 14, 14, 14,
|
||||
15, 15, 15, 15, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16,
|
||||
17, 17, 17, 17, 17, 17, 17, 17,
|
||||
18, 18, 18, 18, 18, 18, 18, 18,
|
||||
18, 19, 19, 19, 19, 19, 19, 19,
|
||||
19, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 21, 21, 21, 21, 21, 21, 21,
|
||||
21, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 30, 30, 30, 30, 30,
|
||||
30, 30, 30, 31, 31, 31, 31, 31
|
||||
};
|
||||
const uint8_t g826_table[256] = {
|
||||
0, 0, 0, 1, 1, 1, 1, 2,
|
||||
2, 2, 2, 3, 3, 3, 3, 4,
|
||||
4, 4, 4, 5, 5, 5, 5, 6,
|
||||
6, 6, 6, 7, 7, 7, 7, 8,
|
||||
8, 8, 8, 9, 9, 9, 9, 10,
|
||||
10, 10, 10, 11, 11, 11, 11, 12,
|
||||
12, 12, 12, 13, 13, 13, 13, 14,
|
||||
14, 14, 14, 15, 15, 15, 15, 16,
|
||||
16, 16, 16, 17, 17, 17, 17, 18,
|
||||
18, 18, 18, 19, 19, 19, 19, 20,
|
||||
20, 20, 20, 21, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 27, 27, 27, 27,
|
||||
28, 28, 28, 28, 29, 29, 29, 29,
|
||||
30, 30, 30, 30, 31, 31, 31, 31,
|
||||
32, 32, 32, 32, 33, 33, 33, 33,
|
||||
34, 34, 34, 34, 35, 35, 35, 35,
|
||||
36, 36, 36, 36, 37, 37, 37, 37,
|
||||
38, 38, 38, 38, 39, 39, 39, 39,
|
||||
40, 40, 40, 40, 41, 41, 41, 41,
|
||||
42, 42, 42, 42, 42, 43, 43, 43,
|
||||
43, 44, 44, 44, 44, 45, 45, 45,
|
||||
45, 46, 46, 46, 46, 47, 47, 47,
|
||||
47, 48, 48, 48, 48, 49, 49, 49,
|
||||
49, 50, 50, 50, 50, 51, 51, 51,
|
||||
51, 52, 52, 52, 52, 53, 53, 53,
|
||||
53, 54, 54, 54, 54, 55, 55, 55,
|
||||
55, 56, 56, 56, 56, 57, 57, 57,
|
||||
57, 58, 58, 58, 58, 59, 59, 59,
|
||||
59, 60, 60, 60, 60, 61, 61, 61,
|
||||
61, 62, 62, 62, 62, 63, 63, 63
|
||||
};
|
||||
32768
src/omv/img/yuv_tab.c
32768
src/omv/img/yuv_tab.c
File diff suppressed because it is too large
Load Diff
@ -854,6 +854,7 @@ int ov2640_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SWNSOR_HW_FLAGS_RGB565_REV, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
#define IMAGE_MODE_JPEG_EN 0x10
|
||||
#define IMAGE_MODE_YUV422 0x00
|
||||
#define IMAGE_MODE_RAW10 0x04
|
||||
#define IMAGE_MODE_RGB565 0x08
|
||||
#define IMAGE_MODE_RGB565 0x09
|
||||
#define IMAGE_MODE_HREF_VSYNC 0x02
|
||||
#define IMAGE_MODE_LBYTE_FIRST 0x01
|
||||
#define IMAGE_MODE_GET_FMT(x) ((x)&0xC)
|
||||
|
||||
@ -483,7 +483,7 @@ static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, FORMAT_CONTROL_MUX, 0x00);
|
||||
break;
|
||||
case PIXFORMAT_RGB565:
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, FORMAT_CONTROL, 0x61);
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, FORMAT_CONTROL, 0x6F);
|
||||
ret |= cambus_writeb2(&sensor->i2c, sensor->slv_addr, FORMAT_CONTROL_MUX, 0x01);
|
||||
break;
|
||||
case PIXFORMAT_YUV422:
|
||||
@ -1030,6 +1030,7 @@ int ov5640_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SWNSOR_HW_FLAGS_RGB565_REV, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -622,6 +622,7 @@ int ov7690_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SWNSOR_HW_FLAGS_RGB565_REV, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -622,6 +622,7 @@ int ov7725_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SWNSOR_HW_FLAGS_RGB565_REV, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -538,6 +538,7 @@ int ov9650_init(sensor_t *sensor)
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_JPEGE, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SWNSOR_HW_FLAGS_RGB565_REV, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -685,9 +685,9 @@ STATIC mp_obj_t py_image_get_pixel(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
if (arg_rgbtuple) {
|
||||
int pixel = IMAGE_GET_RGB565_PIXEL(arg_img, arg_x, arg_y);
|
||||
mp_obj_t pixel_tuple[3];
|
||||
pixel_tuple[0] = mp_obj_new_int(COLOR_R5_TO_R8(COLOR_RGB565_TO_R5(pixel)));
|
||||
pixel_tuple[1] = mp_obj_new_int(COLOR_G6_TO_G8(COLOR_RGB565_TO_G6(pixel)));
|
||||
pixel_tuple[2] = mp_obj_new_int(COLOR_B5_TO_B8(COLOR_RGB565_TO_B5(pixel)));
|
||||
pixel_tuple[0] = mp_obj_new_int(COLOR_RGB565_TO_R8(pixel));
|
||||
pixel_tuple[1] = mp_obj_new_int(COLOR_RGB565_TO_G8(pixel));
|
||||
pixel_tuple[2] = mp_obj_new_int(COLOR_RGB565_TO_B8(pixel));
|
||||
return mp_obj_new_tuple(3, pixel_tuple);
|
||||
} else {
|
||||
return mp_obj_new_int(IMAGE_GET_RGB565_PIXEL(arg_img, arg_x, arg_y));
|
||||
@ -7097,7 +7097,7 @@ mp_obj_t py_image_yuv_to_binary(uint n_args, const mp_obj_t *args, mp_map_t *kw_
|
||||
{
|
||||
const mp_obj_t *arg_vec;
|
||||
py_helper_consume_array(n_args, args, 0, 3, &arg_vec);
|
||||
int8_t y = (mp_obj_get_int(arg_vec[0]) & 255) - 128;
|
||||
int8_t y = mp_obj_get_int(arg_vec[0]) & 255;
|
||||
int8_t u = mp_obj_get_int(arg_vec[1]) & 255;
|
||||
int8_t v = mp_obj_get_int(arg_vec[2]) & 255;
|
||||
uint16_t rgb565 = COLOR_YUV_TO_RGB565(y, u, v);
|
||||
@ -7109,7 +7109,7 @@ mp_obj_t py_image_yuv_to_grayscale(uint n_args, const mp_obj_t *args, mp_map_t *
|
||||
{
|
||||
const mp_obj_t *arg_vec;
|
||||
py_helper_consume_array(n_args, args, 0, 3, &arg_vec);
|
||||
int8_t y = (mp_obj_get_int(arg_vec[0]) & 255) - 128;
|
||||
int8_t y = mp_obj_get_int(arg_vec[0]) & 255;
|
||||
int8_t u = mp_obj_get_int(arg_vec[1]) & 255;
|
||||
int8_t v = mp_obj_get_int(arg_vec[2]) & 255;
|
||||
uint16_t rgb565 = COLOR_YUV_TO_RGB565(y, u, v);
|
||||
@ -7121,7 +7121,7 @@ mp_obj_t py_image_yuv_to_rgb(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
||||
{
|
||||
const mp_obj_t *arg_vec;
|
||||
py_helper_consume_array(n_args, args, 0, 3, &arg_vec);
|
||||
int8_t y = (mp_obj_get_int(arg_vec[0]) & 255) - 128;
|
||||
int8_t y = mp_obj_get_int(arg_vec[0]) & 255;
|
||||
int8_t u = mp_obj_get_int(arg_vec[1]) & 255;
|
||||
int8_t v = mp_obj_get_int(arg_vec[2]) & 255;
|
||||
uint16_t rgb565 = COLOR_YUV_TO_RGB565(y, u, v);
|
||||
@ -7136,7 +7136,7 @@ mp_obj_t py_image_yuv_to_lab(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
||||
{
|
||||
const mp_obj_t *arg_vec;
|
||||
py_helper_consume_array(n_args, args, 0, 3, &arg_vec);
|
||||
int8_t y = (mp_obj_get_int(arg_vec[0]) & 255) - 128;
|
||||
int8_t y = mp_obj_get_int(arg_vec[0]) & 255;
|
||||
int8_t u = mp_obj_get_int(arg_vec[1]) & 255;
|
||||
int8_t v = mp_obj_get_int(arg_vec[2]) & 255;
|
||||
uint16_t rgb565 = COLOR_YUV_TO_RGB565(y, u, v);
|
||||
|
||||
@ -327,14 +327,15 @@ static mp_obj_t py_lcd_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
||||
if (IM_IS_GS(arg_img)) {
|
||||
for (int j=0; j<rect.w; j++) {
|
||||
uint8_t pixel = IM_GET_GS_PIXEL(arg_img, (rect.x + j), (rect.y + i));
|
||||
line[j] = IM_RGB565(IM_R825(pixel),IM_G826(pixel),IM_B825(pixel));
|
||||
line[j] = COLOR_Y_TO_RGB565(pixel);
|
||||
}
|
||||
lcd_write_data(rect.w*2, (uint8_t *) line);
|
||||
} else {
|
||||
lcd_write_data(rect.w*2, (uint8_t *)
|
||||
(((uint16_t *) arg_img->pixels) +
|
||||
((rect.y + i) * arg_img->w) + rect.x));
|
||||
for (int j=0; j<rect.w; j++) {
|
||||
uint16_t pixel = IM_GET_RGB565_PIXEL(arg_img, (rect.x + j), (rect.y + i));
|
||||
line[j] = __REV16(pixel);
|
||||
}
|
||||
}
|
||||
lcd_write_data(rect.w*2, (uint8_t *) line);
|
||||
if (r_pad) {
|
||||
lcd_write_data(r_pad*2, zero); // r_pad < width
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "py_image.h"
|
||||
|
||||
// Crystal frequency in MHZ (float, observe accuracy)
|
||||
// In fact I use 28.63636 MHZ crystal and disable 8x PLL.
|
||||
// In fact I use 28.63636 MHZ crystal and disable 8x PLL.
|
||||
// But calculation worong if I change XTAL_MHZ value.
|
||||
#define XTAL_MHZ 3.579545
|
||||
// Line length in microseconds (float, observe accuracy)
|
||||
@ -31,9 +31,9 @@
|
||||
// Width, in PLL clocks, of each pixel
|
||||
// Used 4 to 8 for 160x120 pics
|
||||
#define PLLCLKS_PER_PIXEL 9 // 4 is too short.
|
||||
// Extra bytes can be added to end of picture lines to prevent pic-to-proto
|
||||
// border artifacts. 8 is a good value. 0 can be tried to test, if there is
|
||||
// no need for extra bytes.
|
||||
// Extra bytes can be added to end of picture lines to prevent pic-to-proto
|
||||
// border artifacts. 8 is a good value. 0 can be tried to test, if there is
|
||||
// no need for extra bytes.
|
||||
#define BEXTRA 8
|
||||
|
||||
//// Protolines ////
|
||||
@ -41,7 +41,7 @@
|
||||
// Reserve memory for this number of different prototype lines
|
||||
// (prototype lines are used for sync timing, porch and border area)
|
||||
#define PROTOLINES 3
|
||||
// if your real protoline lenght is longer than one slot, you must
|
||||
// if your real protoline lenght is longer than one slot, you must
|
||||
// use several slots per proto and there are total 16 slots
|
||||
#define PROTOLINE_LENGTH_WORDS 512
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
#define PROTOLINE_BYTE_ADDRESS(n) (PROTOLINE_LENGTH_WORDS) *2 *(n)) // 512 * 2 * n = 1024*n
|
||||
#define PROTOLINE_WORD_ADDRESS(n) (PROTOLINE_LENGTH_WORDS * (n)) // 512 * n = 512*n
|
||||
|
||||
// These are for proto lines and so format is VVVVUUUUYYYYYYYY
|
||||
// These are for proto lines and so format is VVVVUUUUYYYYYYYY
|
||||
// Sync is always 0
|
||||
#define SYNC_LEVEL 0x0000
|
||||
// 285 mV to 75 ohm load
|
||||
@ -84,7 +84,7 @@
|
||||
// NTSC sync to blanking end time is 10.5 us
|
||||
#define BLANK_END_US 9.155
|
||||
#define BLANKEND ((uint16_t)(BLANK_END_US*XTAL_MHZ-10.0/8.0))
|
||||
// Front porch starts at the end of the line, at 62.5us
|
||||
// Front porch starts at the end of the line, at 62.5us
|
||||
#define FRPORCH_US 61.8105
|
||||
#define FRPORCH ((uint16_t)(FRPORCH_US*XTAL_MHZ-10.0/8.0))
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
/// PAL sync to blanking end time is 10.5 us
|
||||
#define BLANK_END_US 10.5
|
||||
#define BLANKEND ((uint16_t)(BLANK_END_US*XTAL_MHZ-10.0/8.0))
|
||||
/// Front porch starts at the end of the line, at 62.5us
|
||||
/// Front porch starts at the end of the line, at 62.5us
|
||||
#define FRPORCH_US 62.5
|
||||
#define FRPORCH ((uint16_t)(FRPORCH_US*XTAL_MHZ-10.0/8.0))
|
||||
*/
|
||||
@ -127,7 +127,7 @@
|
||||
#define ENDLINE STARTLINE + YPIXELS
|
||||
// The first pixel of the picture area, the X direction.
|
||||
#define STARTPIX (BLANKEND+6)
|
||||
// The last pixel of the picture area. Set PIXELS to wanted value and suitable
|
||||
// The last pixel of the picture area. Set PIXELS to wanted value and suitable
|
||||
// ENDPIX value is calculated.
|
||||
#define XPIXELS 160
|
||||
#define ENDPIX ((uint16_t)(STARTPIX+PLLCLKS_PER_PIXEL*XPIXELS/8))
|
||||
@ -157,10 +157,10 @@
|
||||
|
||||
//// Index start /////
|
||||
|
||||
#define PROTO_AREA_WORDS (PROTOLINE_LENGTH_WORDS * PROTOLINES)
|
||||
#define PROTO_AREA_WORDS (PROTOLINE_LENGTH_WORDS * PROTOLINES)
|
||||
#define INDEX_START_LONGWORDS ((PROTO_AREA_WORDS+1)/2)
|
||||
#define INDEX_START_WORDS (INDEX_START_LONGWORDS * 2)
|
||||
#define INDEX_START_BYTES (INDEX_START_WORDS * 2)
|
||||
#define INDEX_START_BYTES (INDEX_START_WORDS * 2)
|
||||
|
||||
//// Pattern generator microcode ////
|
||||
|
||||
@ -172,14 +172,14 @@
|
||||
|
||||
// Bits 5:3
|
||||
// Pick 1..8
|
||||
#define PICK_BITS(a) (((a)-1)<<3)
|
||||
#define PICK_BITS(a) (((a)-1)<<3)
|
||||
|
||||
// Bits 2:0
|
||||
// Bits 2:0
|
||||
// Shift 0..6
|
||||
#define SHIFT_BITS(a) (a)
|
||||
|
||||
// The microcode is given as a 32-bit parameter to the SpiWrite-function, and must
|
||||
// therefore be typecasted to unsigned long. Otherwise, if using Arduino, the values
|
||||
// therefore be typecasted to unsigned long. Otherwise, if using Arduino, the values
|
||||
// shifted beyond 16-bit range are lost. VS1005 and VS1010 would not require typecasting
|
||||
// in this instance.
|
||||
// b=>u
|
||||
@ -406,17 +406,17 @@ void VS23Init()
|
||||
SpiWrite(WRITE_STATUS, 0, 0x40, 0);
|
||||
// set GPIO output, high
|
||||
SpiWrite(GPIOCTL, 0, 0xFF, 0);
|
||||
// Write picture start and end values. These are the
|
||||
// Write picture start and end values. These are the
|
||||
// left and right limits of the visible picture.
|
||||
SpiWrite(PICSTART, 0, (STARTPIX-1), 1);
|
||||
SpiWrite(PICEND, 0, (ENDPIX-1), 1);
|
||||
|
||||
|
||||
// Enable and select PLL clock.
|
||||
// SpiWrite(VDCTRL1, 0, (VDCTRL1_PLL_ENABLE) | (VDCTRL1_SELECT_PLL_CLOCK), 1);
|
||||
SpiWrite(VDCTRL1, 0, VDCTRL1_PLL_ENABLE, 1);
|
||||
|
||||
// Clear memory by filling it with 0. Memory is 65536 16-bit words, and first 24-bits
|
||||
// are used for the starting address. The address then autoincrements when the zero
|
||||
// are used for the starting address. The address then autoincrements when the zero
|
||||
// data is being sent.
|
||||
// this is slow, Can not clear.
|
||||
// CS_PIN_WRITE(false);
|
||||
@ -424,11 +424,11 @@ void VS23Init()
|
||||
// for (int i=0; i<65539; i++) SpiSendWord(0); // Address and data.
|
||||
// CS_PIN_WRITE(true);
|
||||
|
||||
// Set length of one complete line (in PLL (VClk) clocks).
|
||||
// Does not include the fixed 10 cycles of sync level at the beginning
|
||||
// of the lines.
|
||||
// Set length of one complete line (in PLL (VClk) clocks).
|
||||
// Does not include the fixed 10 cycles of sync level at the beginning
|
||||
// of the lines.
|
||||
SpiWrite(LINELEN, 0, PLLCLKS_PER_LINE, 1);
|
||||
|
||||
|
||||
// Set microcode program for picture lines. Each OP is one VClk cycle.
|
||||
SpiWrite(PROGRAM, 0, ((OP4 << 24) | (OP3 << 16) | (OP2 << 8) | (OP1)), 0);
|
||||
|
||||
@ -444,14 +444,14 @@ void VS23Init()
|
||||
protoline(0, BLANKEND, FRPORCH, BLACK_LEVEL); // Set the color level to black
|
||||
protoline(0, 0, SYNC, SYNC_LEVEL); // Set HSYNC
|
||||
protoline(0, BURST, BURSTDUR, BURST_LEVEL); // Set color burst
|
||||
|
||||
|
||||
// Construct protoline 1. This is a short+short VSYNC line
|
||||
protoline(1, 0, COLORCLKS_PER_LINE, BLANK_LEVEL);
|
||||
protoline(1, 0, SHORTSYNC, SYNC_LEVEL); // Short sync at the beginning of line
|
||||
protoline(1, COLORCLKS_LINE_HALF, SHORTSYNCM, SYNC_LEVEL); // Short sync at the middle of line
|
||||
|
||||
|
||||
// Construct protoline 2. This is a long+long VSYNC line
|
||||
protoline(2, 0, COLORCLKS_PER_LINE, BLANK_LEVEL);
|
||||
protoline(2, 0, COLORCLKS_PER_LINE, BLANK_LEVEL);
|
||||
protoline(2, 0, LONGSYNC, SYNC_LEVEL); // Long sync at the beginning of line
|
||||
protoline(2, COLORCLKS_LINE_HALF, LONGSYNCM, SYNC_LEVEL); // Long sync at the middle of line
|
||||
|
||||
@ -464,8 +464,8 @@ void VS23Init()
|
||||
// for (int i=0; i<ENDLINE-STARTLINE; i++) SetPicIndex(i + STARTLINE, PICLINE_BYTE_ADDRESS(i),0);
|
||||
for (int i=0; i<(ENDLINE-STARTLINE)*2; i++) SetPicIndex(i + STARTLINE, PICLINE_BYTE_ADDRESS(i/2),0);
|
||||
// Enable Video Display Controller, set video mode to NTSC, set program length and linecount.
|
||||
SpiWrite(VDCTRL2, 0,
|
||||
VDCTRL2_ENABLE_VIDEO |
|
||||
SpiWrite(VDCTRL2, 0,
|
||||
VDCTRL2_ENABLE_VIDEO |
|
||||
VDCTRL2_NTSC |
|
||||
VDCTRL2_PROGRAM_LENGTH |
|
||||
VDCTRL2_LINECOUNT, 1);
|
||||
@ -577,7 +577,7 @@ static mp_obj_t py_tv_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
|
||||
uint16_t pixel = IM_GET_RGB565_PIXEL(arg_img, x, y);
|
||||
uint8_t b4 = (COLOR_RGB565_TO_U(pixel)) & 0xF0;
|
||||
uint8_t a4 = ((-COLOR_RGB565_TO_V(pixel))>>4) & 0x0F;
|
||||
uint8_t y8 = ((COLOR_RGB565_TO_Y(pixel)+128));
|
||||
uint8_t y8 = COLOR_RGB565_TO_Y(pixel);
|
||||
line[2*i] = b4 | a4;
|
||||
line[2*i + 1] = y8;
|
||||
}
|
||||
|
||||
@ -1103,6 +1103,29 @@ void *unaligned_memcpy(void *dest, void *src, size_t n)
|
||||
#endif
|
||||
}
|
||||
|
||||
// ARM Cortex-M4/M7 Processors can access memory using unaligned 32-bit reads/writes.
|
||||
void *unaligned_memcpy_rev16(void *dest, void *src, size_t n)
|
||||
{
|
||||
uint32_t *dest32 = (uint32_t *) dest;
|
||||
uint32_t *src32 = (uint32_t *) src;
|
||||
|
||||
// TODO: Make this faster using only 32-bit aligned reads/writes with data shifting.
|
||||
#if defined(MCU_SERIES_F4) || defined(MCU_SERIES_F7) || defined(MCU_SERIES_H7)
|
||||
for (; n > 2; n -= 2) {
|
||||
*dest32++ = __REV16(*src32++);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t *dest16 = (uint16_t *) dest32;
|
||||
uint16_t *src16 = (uint16_t *) src32;
|
||||
|
||||
for (; n > 0; n -= 1) {
|
||||
*dest16++ = __REV16(*src16++);
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
// Stop allowing new data in on the end of the frame and let snapshot know that the frame has been
|
||||
// received. Note that DCMI_DMAConvCpltUser() is called before DCMI_IT_FRAME is enabled by
|
||||
// DCMI_DMAXferCplt() so this means that the last line of data is *always* transferred before
|
||||
@ -1207,7 +1230,11 @@ void DCMI_DMAConvCpltUser(uint32_t addr)
|
||||
case PIXFORMAT_RGB565:
|
||||
dst16 += (offset - MAIN_FB()->y) * MAIN_FB()->w;
|
||||
src16 += MAIN_FB()->x;
|
||||
unaligned_memcpy(dst16, src16, MAIN_FB()->w * sizeof(uint16_t));
|
||||
if (SENSOR_HW_FLAGS_GET(&sensor, SWNSOR_HW_FLAGS_RGB565_REV)) {
|
||||
unaligned_memcpy_rev16(dst16, src16, MAIN_FB()->w);
|
||||
} else {
|
||||
unaligned_memcpy(dst16, src16, MAIN_FB()->w * sizeof(uint16_t));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1244,9 +1271,16 @@ void DCMI_DMAConvCpltUser(uint32_t addr)
|
||||
case PIXFORMAT_RGB565:
|
||||
dst16 += offset - MAIN_FB()->y;
|
||||
src16 += MAIN_FB()->x;
|
||||
for (int i = MAIN_FB()->w, h = MAIN_FB()->h; i; i--) {
|
||||
*dst16 = *src16++;
|
||||
dst16 += h;
|
||||
if (SENSOR_HW_FLAGS_GET(&sensor, SWNSOR_HW_FLAGS_RGB565_REV)) {
|
||||
for (int i = MAIN_FB()->w, h = MAIN_FB()->h; i; i--) {
|
||||
*dst16 = __REV16(*src16++);
|
||||
dst16 += h;
|
||||
}
|
||||
} else {
|
||||
for (int i = MAIN_FB()->w, h = MAIN_FB()->h; i; i--) {
|
||||
*dst16 = *src16++;
|
||||
dst16 += h;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -139,6 +139,7 @@ typedef enum {
|
||||
#define SENSOR_HW_FLAGS_PIXCK (2) // pixel clock edge.
|
||||
#define SENSOR_HW_FLAGS_FSYNC (3) // hardware frame sync.
|
||||
#define SENSOR_HW_FLAGS_JPEGE (4) // hardware JPEG encoder.
|
||||
#define SWNSOR_HW_FLAGS_RGB565_REV (5) // byte reverse rgb565.
|
||||
#define SENSOR_HW_FLAGS_GET(s, x) ((s)->hw_flags & (1<<x))
|
||||
#define SENSOR_HW_FLAGS_SET(s, x, v) ((s)->hw_flags |= (v<<x))
|
||||
#define SENSOR_HW_FLAGS_CLR(s, x) ((s)->hw_flags &= ~(1<<x))
|
||||
|
||||
@ -20,9 +20,9 @@ if False: # 1D illumination invariant image
|
||||
sys.stdout.write("const uint8_t invariant_table[65536] = {\n") # 65536 * 1
|
||||
for i in range(65536):
|
||||
|
||||
r = ((((i >> 3) & 31) * 255) + 15.5) // 31
|
||||
g = (((((i & 7) << 3) | (i >> 13)) * 255) + 31.5) // 63
|
||||
b = ((((i >> 8) & 31) * 255) + 15.5) // 31
|
||||
r = ((((i >> 11) & 31) * 255) + 15.5) // 31
|
||||
g = ((((i >> 5) & 63) * 255) + 31.5) // 63
|
||||
b = (((i & 31) * 255) + 15.5) // 31
|
||||
|
||||
# http://ai.stanford.edu/~alireza/publication/cic15.pdf
|
||||
|
||||
@ -111,10 +111,10 @@ if True: # 2D illumination invariant image
|
||||
p_th_01 = e_t_x * e_t_y
|
||||
p_th_10 = e_t_y * e_t_x
|
||||
p_th_11 = e_t_y * e_t_y
|
||||
|
||||
|
||||
x_th_x = (p_th_00 * chi_x) + (p_th_01 * chi_y)
|
||||
x_th_y = (p_th_10 * chi_x) + (p_th_11 * chi_y)
|
||||
|
||||
|
||||
r_chi = (x_th_x * 0.7071) + (x_th_y * 0.4082)
|
||||
g_chi = (x_th_x * -0.7071) + (x_th_y * 0.4082)
|
||||
b_chi = (x_th_x * 0.0000) + (x_th_y * -0.8164)
|
||||
@ -124,7 +124,7 @@ if True: # 2D illumination invariant image
|
||||
b_chi_invariant = math.exp(b_chi)
|
||||
|
||||
chi_invariant_sum = r_chi_invariant + g_chi_invariant + b_chi_invariant
|
||||
|
||||
|
||||
r_chi_invariant_m = 0.0
|
||||
g_chi_invariant_m = 0.0
|
||||
b_chi_invariant_m = 0.0
|
||||
|
||||
@ -26,7 +26,7 @@ sys.stdout.write("const uint16_t rainbow_table[%d] = {\n" % NUM_COL)
|
||||
for i in range(NUM_COL):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("0x%04X" % (((col[i]&0x00ff)<<8)|((col[i]&0xff00)>>8)))
|
||||
sys.stdout.write("0x%04X" % col[i])
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != (NUM_COL-1):
|
||||
@ -302,7 +302,7 @@ sys.stdout.write("const uint16_t ironbow_table[%d] = {\n" % NUM_COL)
|
||||
for i in range(NUM_COL):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("0x%04X" % (((col[i]&0x00ff)<<8)|((col[i]&0xff00)>>8)))
|
||||
sys.stdout.write("0x%04X" % col[i])
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != (NUM_COL-1):
|
||||
|
||||
@ -19,9 +19,9 @@ sys.stdout.write("#include <stdint.h>\n")
|
||||
sys.stdout.write("const int8_t lab_table[196608] = {\n") # 65536 * 3
|
||||
for i in range(65536):
|
||||
|
||||
r = ((((i >> 3) & 31) * 255) + 15.5) // 31
|
||||
g = (((((i & 7) << 3) | (i >> 13)) * 255) + 31.5) // 63
|
||||
b = ((((i >> 8) & 31) * 255) + 15.5) // 31
|
||||
r = ((((i >> 11) & 31) * 255) + 15.5) // 31
|
||||
g = ((((i >> 5) & 63) * 255) + 31.5) // 63
|
||||
b = (((i & 31) * 255) + 15.5) // 31
|
||||
|
||||
# https://en.wikipedia.org/wiki/SRGB (The reverse transformation)
|
||||
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python2
|
||||
# This file is part of the OpenMV project.
|
||||
#
|
||||
# Copyright (c) 2013-2019 Ibrahim Abdelkader <iabdalkader@openmv.io>
|
||||
# Copyright (c) 2013-2019 Kwabena W. Agyeman <kwagyeman@openmv.io>
|
||||
#
|
||||
# This work is licensed under the MIT license, see the file LICENSE for details.
|
||||
#
|
||||
# This script generates RGB to RGB lookup table.
|
||||
|
||||
import sys
|
||||
sys.stdout.write("#include <stdint.h>\n")
|
||||
|
||||
sys.stdout.write("const uint8_t rb528_table[32] = {\n")
|
||||
for i in range(32):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("%3d" % (((i * 255) + 15.5) // 31))
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != 31:
|
||||
sys.stdout.write(",\n")
|
||||
else:
|
||||
sys.stdout.write("\n};\n")
|
||||
|
||||
sys.stdout.write("const uint8_t g628_table[64] = {\n")
|
||||
for i in range(64):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("%3d" % (((i * 255) + 31.5) // 63))
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != 63:
|
||||
sys.stdout.write(",\n")
|
||||
else:
|
||||
sys.stdout.write("\n};\n")
|
||||
|
||||
sys.stdout.write("const uint8_t rb825_table[256] = {\n")
|
||||
for i in range(256):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("%3d" % (((i * 31) + 127.5) // 255))
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != 255:
|
||||
sys.stdout.write(",\n")
|
||||
else:
|
||||
sys.stdout.write("\n};\n")
|
||||
|
||||
sys.stdout.write("const uint8_t g826_table[256] = {\n")
|
||||
for i in range(256):
|
||||
if not (i % 8):
|
||||
sys.stdout.write(" ")
|
||||
sys.stdout.write("%3d" % (((i * 63) + 127.5) // 255))
|
||||
if (i + 1) % 8:
|
||||
sys.stdout.write(", ")
|
||||
elif i != 255:
|
||||
sys.stdout.write(",\n")
|
||||
else:
|
||||
sys.stdout.write("\n};\n")
|
||||
@ -15,9 +15,9 @@ sys.stdout.write("#include <stdint.h>\n")
|
||||
sys.stdout.write("const int8_t yuv_table[196608] = {\n") # 65536 * 3
|
||||
for i in range(65536):
|
||||
|
||||
r = ((((i >> 3) & 31) * 255) + 15.5) // 31
|
||||
g = (((((i & 7) << 3) | (i >> 13)) * 255) + 31.5) // 63
|
||||
b = ((((i >> 8) & 31) * 255) + 15.5) // 31
|
||||
r = ((((i >> 11) & 31) * 255) + 15.5) // 31
|
||||
g = ((((i >> 5) & 63) * 255) + 31.5) // 63
|
||||
b = (((i & 31) * 255) + 15.5) // 31
|
||||
|
||||
# https://en.wikipedia.org/wiki/YCbCr (ITU-R BT.601 conversion)
|
||||
y = int((r * +0.299000) + (g * +0.587000) + (b * +0.114000)) - 128;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user